Professional Documents
Culture Documents
Semafora OntoBroker 6 - 3 Reference Manual 2020
Semafora OntoBroker 6 - 3 Reference Manual 2020
Table of Content
General
................................................................................................................................................9
Information
Na ..........................................................................................................................................................................................9
mi ng the Screen El ements
Typogra
..........................................................................................................................................................................................10
phi c Conventi ons
Ins
..........................................................................................................................................................................................10
ta l l a ti on
Ontol
..........................................................................................................................................................................................12
ogy La ngua ges
Using
................................................................................................................................................14
Ontobroker as RDF Triple Store
Introducti
..........................................................................................................................................................................................14
on
New
..........................................................................................................................................................................................14
a nd Noteworthy
Confi
..........................................................................................................................................................................................14
gura ti on
API
..........................................................................................................................................................................................15
By Exa mpl
.......................................................................................................................................................................15
e
SPARQL Query
.......................................................................................................................................................................16
SPARQL Upda
.......................................................................................................................................................................17
te
Fa ctory Overvi
.......................................................................................................................................................................17
ew
RDF
..........................................................................................................................................................................................18
Compa ti bi l i ty
Supported
.......................................................................................................................................................................18
Forma ts
Interna l.......................................................................................................................................................................18
Model a nd Round-Tri ppi ng
Inferenci
..........................................................................................................................................................................................19
ng
SPARQL
..........................................................................................................................................................................................20
Error Ha ndl
.......................................................................................................................................................................20
i ng
Sta nda rd.......................................................................................................................................................................20
Conforma nce
Extens i on
.......................................................................................................................................................................21
Functi ons
Extended
.......................................................................................................................................................................22
Query Opti ons
SPARQL
..........................................................................................................................................................................................22
Endpoi nt
Queri es .......................................................................................................................................................................23
Upda tes.......................................................................................................................................................................23
FAQ
..........................................................................................................................................................................................24
OntoBroker
................................................................................................................................................25
GUI
Admi
..........................................................................................................................................................................................25
ni s tra ti on Cons ol e GUI
Sta
..........................................................................................................................................................................................31
rti ng OntoBroker
Speci
..........................................................................................................................................................................................34
fyi ng the VM
Sta
..........................................................................................................................................................................................35
rti ng the Webcons ol e
Webcons
..........................................................................................................................................................................................36
ol e GUI
Converti
..........................................................................................................................................................................................39
ng Ontol ogi es
Storage
................................................................................................................................................44
Systems
Data
................................................................................................................................................45
Integration
Crea
..........................................................................................................................................................................................45
ti on of da ta ba s e ma ppi ng rul es
2
OntoBroker 6.3
Opti
..........................................................................................................................................................................................46
mi za ti on
Nul
..........................................................................................................................................................................................47
l Va l ues
Cha
..........................................................................................................................................................................................48
ngi ng the Connecti on Da ta
Connector
..........................................................................................................................................................................................48
ca che cl ea r comma nd
MergeImports
..........................................................................................................................................................................................48
Integra
..........................................................................................................................................................................................49
ti on Scena ri o
Supported
..........................................................................................................................................................................................53
Common Da ta types
Web
..........................................................................................................................................................................................54
Servi ce Connector
REST
..........................................................................................................................................................................................55
Webs ervi ce Connector
SPARQL
..........................................................................................................................................................................................61
Connectors
LOD
..........................................................................................................................................................................................61
Integra ti on
Supported
................................................................................................................................................63
Import Formats
Query
................................................................................................................................................64
Languages for ObjectLogic
ObjectLogi
..........................................................................................................................................................................................64
c
Query Opti
.......................................................................................................................................................................64
ons
SPARQL
..........................................................................................................................................................................................72
Run
................................................................................................................................................74
Queries by Query Id
RIF
................................................................................................................................................75
Overvi
..........................................................................................................................................................................................75
ew
ObjectLogi
..........................................................................................................................................................................................75
c -> RIF
Ma ppi ng.......................................................................................................................................................................75
Annota ti.......................................................................................................................................................................80
ons a nd Formul a IDs
Fora l l -Cl.......................................................................................................................................................................80
os i ng
Modul es.......................................................................................................................................................................80
Uns upported
.......................................................................................................................................................................81
ObjectLogi c Fea tures
RIF
..........................................................................................................................................................................................81
-> ObjectLogi c
Al l owed.......................................................................................................................................................................81
RIF Formul a s
Pa rti a l l y.......................................................................................................................................................................81
Supported RIF Fea tures
Uns upported
.......................................................................................................................................................................81
RIF Fea tures
API
..........................................................................................................................................................................................82
Import .......................................................................................................................................................................82
Export .......................................................................................................................................................................82
Project
................................................................................................................................................83
Files
Ba..........................................................................................................................................................................................83
s i c Exa mpl es
Loa
..........................................................................................................................................................................................84
di ng a n Ontol ogy Fi l e i nto a Speci fi c Modul e
Performa
..........................................................................................................................................................................................84
nce Opti mi za ti on wi th Project Fi l es
Materialization
................................................................................................................................................85
Ba..........................................................................................................................................................................................85
s i c Us a ge
Sta
..........................................................................................................................................................................................85
nda rd Ma teri a l i za ti on
Upda
..........................................................................................................................................................................................85
ta bl e Ma teri a l i za ti on
3
OntoBroker 6.3
Ma
..........................................................................................................................................................................................87
teri a l i za ti on Comma nds
Tra
..........................................................................................................................................................................................88
ci ng the Ma teri a l i za ti on
Al..........................................................................................................................................................................................89
l Confi gura ti on Opti ons
Ma
..........................................................................................................................................................................................89
teri a l i za ti on wi th the API
Ma
..........................................................................................................................................................................................89
teri a l i za ti on of Sta nda rd Axi oms
Interfaces
................................................................................................................................................91
to OntoBroker
Socket
..........................................................................................................................................................................................91
Cl i ent API
OntoBroker
..........................................................................................................................................................................................92
Ja va API
Ontol ogy.......................................................................................................................................................................93
Ma na gement
Da ta Ma.......................................................................................................................................................................94
ni pul a ti on
Da ta model
.......................................................................................................................................................................99
Li s tener
Autocompl
.......................................................................................................................................................................100
ete
Progres.......................................................................................................................................................................102
s Li s tener
Na mes.......................................................................................................................................................................103
pa ces a nd Modul es
OntoBroker
..........................................................................................................................................................................................105
a nd Web Servi ces (SOAP/WSDL)
Webs ervi
.......................................................................................................................................................................105
ce Interfa ce
Depl oyment
.......................................................................................................................................................................106
Loa d Ba.......................................................................................................................................................................106
l a nci ng for Web Servi ces
Pa gi ng .......................................................................................................................................................................107
Support for Web Servi ce
Extens i.......................................................................................................................................................................108
ons Di rectory to Depl oy Web Servi ces
How
..........................................................................................................................................................................................109
to Acces s OntoBroker From Other Progra mmi ng La ngua ges
Web Servi
.......................................................................................................................................................................109
ce Interfa ce
Acces s i.......................................................................................................................................................................109
ng Web Servi ce wi th .NET
Acces s i.......................................................................................................................................................................110
ng Web Servi ce wi th Ja va
Us
..........................................................................................................................................................................................112
i ng the Extens i on API to Devel op OntoBroker Extens i ons
Devel opi
.......................................................................................................................................................................112
ng Your Own Bui l t-i ns
Devel opi
.......................................................................................................................................................................139
ng Your Own Rewri ters
Extens i.......................................................................................................................................................................141
ons Di rectory for Depl oyi ng a Web Servi ce
Us e OntoBroker
.......................................................................................................................................................................142
Exa mpl es
UIMA
..........................................................................................................................................................................................142
Sema nti
.......................................................................................................................................................................143
c Content Ana l yti cs (SCA)
Role-Based
................................................................................................................................................144
Security
Rol
..........................................................................................................................................................................................144
e-Ba s ed Securi ty
Rea
..........................................................................................................................................................................................144
l ms
Modul
..........................................................................................................................................................................................145
e Permi s s i ons
Property
..........................................................................................................................................................................................145
Permi s s i ons
Ba
..........................................................................................................................................................................................146
s i c Confi gura ti on
Authenti
..........................................................................................................................................................................................146
ca ti on/Logi n
Confi
..........................................................................................................................................................................................147
gura ti on of the Securi ty Context
Model
..........................................................................................................................................................................................148
i ng the Securi ty Modul e Rea l m wi th OntoStudi o
Ma
..........................................................................................................................................................................................149
ppi ng Groups a nd Rol es from Externa l Rea l ms l i ke LDAP
Acces
..........................................................................................................................................................................................151
s Res tri cti ons for Comma nds
Support
..........................................................................................................................................................................................152
for mul ti pl e pri nci pa l Suffi x i n Acti veDi rectory
4
OntoBroker 6.3
Other
..........................................................................................................................................................................................152
Acces s Res tri cti ons
Permi
..........................................................................................................................................................................................152
s s i ons
Cus tom.......................................................................................................................................................................153
Permi s s i ons
Termi
..........................................................................................................................................................................................154
nol ogy Gl os s a ry
Configuring
................................................................................................................................................156
OntoBroker
Confi
..........................................................................................................................................................................................156
gura ti on GUI
Ba s i c Setti
.......................................................................................................................................................................156
ngs
Opti mi za
.......................................................................................................................................................................157
ti on Setti ngs
Other Setti
.......................................................................................................................................................................158
ngs
Pa
..........................................................................................................................................................................................159
ra l l el i za ti on Setti ngs
Performa
..........................................................................................................................................................................................160
nce-Rel a ted Confi gura ti on Swi tches
Geneti c.......................................................................................................................................................................160
Opti mi zer
El i mi na.......................................................................................................................................................................161
teDupl i ca tes
ConceptNa
.......................................................................................................................................................................162
mes Ground
Attri buteNa
.......................................................................................................................................................................163
mes Ground
Wel
..........................................................................................................................................................................................163
l founded Eva l ua ti on
Us
..........................................................................................................................................................................................163
i ng OntoBroker wi th a Pers i s tent Da ta model
Confi gura
.......................................................................................................................................................................163
ti on
Da ta ba.......................................................................................................................................................................164
s e Fi l e La yout
Confi gura
.......................................................................................................................................................................164
ti on Va l ues for Performa nce Tuni ng
Ba ckup.......................................................................................................................................................................165
Onl i ne .......................................................................................................................................................................165
Ba ckup
Confi
..........................................................................................................................................................................................165
gura ti on Swi tches for the Server
OntoBroker
................................................................................................................................................167
Performance Tuning
Choos
..........................................................................................................................................................................................167
i ng a n Eva l ua ti on Method
Eva l ua ti.......................................................................................................................................................................167
on Methods
BottomUp
.......................................................................................................................................................................168
Eva l ua tors
Choos i ng
.......................................................................................................................................................................169
a Stora ge Sys tem/Eva l ua ti on Method/Bottom-Up Eva l ua tor
Confi g Opti
.......................................................................................................................................................................169
mi zer
Opti
..........................................................................................................................................................................................170
mi zers
El i mi na.......................................................................................................................................................................170
te Redunda nt Li tera l s
Propa ga.......................................................................................................................................................................170
te Cons tra i nts
Rul e Unfol
.......................................................................................................................................................................170
di ng
Equa l Uni
.......................................................................................................................................................................171
fy Rewri ter
Shri nkDBAcces
.......................................................................................................................................................................171
s (Rewri ter for Externa l Da ta ba s e Acces s )
FLToSql.......................................................................................................................................................................171
Rewri ter (Rewri ter For Externa l Da ta ba s e Acces s )
Rewri ter
.......................................................................................................................................................................171
for Propa ga ti on of Ground Terms i n Rul e Gra ph
Schema.......................................................................................................................................................................172
Opti mi zer
El i mi na.......................................................................................................................................................................172
te Bodi es
Fra meOpti
.......................................................................................................................................................................172
mi zer
Rewri ter
.......................................................................................................................................................................173
for Tra ns i ti vi ty Rul es
MergeImports
.......................................................................................................................................................................173
Opti
..........................................................................................................................................................................................173
mi zi ng the Sequence of Body Li tera l s i n Rul es
Us i ng the
.......................................................................................................................................................................174
Geneti c Opti mi zer
5
OntoBroker 6.3
Hi l l cl i mbi
.......................................................................................................................................................................175
ng Opti mi zer
BodyOrderi
.......................................................................................................................................................................176
ng
Tra
..........................................................................................................................................................................................177
ci ng the Eva l ua ti on Proces s
Us
..........................................................................................................................................................................................177
e Ma teri a l i za ti on of Rul es a nd/or Axi oms
Rule
................................................................................................................................................178
Management
Explanations
................................................................................................................................................179
File
................................................................................................................................................183
Encodings and Unicode
OntoBroker
................................................................................................................................................184
Server
La
..........................................................................................................................................................................................184
unchi ng OntoBroker
New Confi
.......................................................................................................................................................................185
gura ti on Pa ra meters
Us
..........................................................................................................................................................................................187
e the OntoBroker Server from comma ndl i ne
Server
..........................................................................................................................................................................................188
Comma nds
Ba s i c Comma
.......................................................................................................................................................................190
nds
Prepa red
.......................................................................................................................................................................194
Queri es
Opti mi zer
.......................................................................................................................................................................196
Comma nds
Server Comma
.......................................................................................................................................................................198
nds for Confi gura ti on Opti mi zer
Loa d Sa.......................................................................................................................................................................199
ve
Drop Modul
.......................................................................................................................................................................199
e
Del ete .......................................................................................................................................................................199
Rul e
Ses
..........................................................................................................................................................................................200
s i ons i n OntoBroker
Run
..........................................................................................................................................................................................202
Groovy Scri pts
Query
..........................................................................................................................................................................................203
Cl i ent
OntoBroker
................................................................................................................................................206
Tools
Appendix
................................................................................................................................................210
Ontol
..........................................................................................................................................................................................210
ogy Tra ns forma ti on
Rul es a.......................................................................................................................................................................211
nd Queri es
RDF Schema
.......................................................................................................................................................................211
to ObjectLogi c
ObjectLogi
.......................................................................................................................................................................211
c to OWL
Ba s i c Tra
.......................................................................................................................................................................212
ns forma ti ons
OWL to.......................................................................................................................................................................214
ObjectLogi c
Compl ex
.......................................................................................................................................................................215
Cl a s s Expres s i ons
OWL2 (RL)
.......................................................................................................................................................................215
i n ObjectLogi c
Throughput
..........................................................................................................................................................................................226
Benchma rk
Ra
..........................................................................................................................................................................................227
nge-Res tri cted Rul es
Bui
..........................................................................................................................................................................................227
l t-i ns
Informa.......................................................................................................................................................................238
ti on a bout _queryIndex/10
ObjectLogi
.......................................................................................................................................................................243
c Bui l t-i ns
Genera.......................................................................................................................................................................247
l Synta cti c Cha nges
Da ta Types
.......................................................................................................................................................................250
Aggrega
..........................................................................................................................................................................................266
ti ons
Connectors
..........................................................................................................................................................................................267
6
OntoBroker 6.3
Properti
..........................................................................................................................................................................................268
es Setti ngs
Sta rt-Up
.......................................................................................................................................................................269
Setti ngs
Opti mi zer
.......................................................................................................................................................................270
Setti ngs
Tra ci ng.......................................................................................................................................................................270
a nd Debuggi ng Setti ngs
Performa
.......................................................................................................................................................................271
nce-Rel a ted Setti ngs
Securi ty.......................................................................................................................................................................271
(Authenti ca ti on & Authori za ti on)
Pa ra l l el.......................................................................................................................................................................271
i za ti on Setti ngs
Ma teri a.......................................................................................................................................................................272
l i za ti on Setti ngs
Loggi ng-Rel
.......................................................................................................................................................................273
a ted Setti ngs
Server Setti
.......................................................................................................................................................................273
ngs
H2 Stora
.......................................................................................................................................................................273
ge Opti ons
Ful l text.......................................................................................................................................................................274
Indexer Setti ngs
Connector
.......................................................................................................................................................................279
Ca che Opti ons
Audi
..........................................................................................................................................................................................279
ti ng
Logged.......................................................................................................................................................................280
Informa ti on
Step by.......................................................................................................................................................................282
s tep gui de
Cha
..........................................................................................................................................................................................283
ngel og
7
OntoBroker 6.3
8
OntoBroker 6.3 Genera l Informa ti on
1 General Information
1.1 Naming the Screen Elements
Screen-Element Example
Ta bs
Na vi ga ti on Tree
Sel ecti on Fi el d
(Opens by cl i cki ng on the bl a ck tri a ngl e)
Check Box
(i na cti ve) (a cti ve)
Button
9
OntoBroker 6.3 Genera l Informa ti on
1.3 Installation
Installing OntoBroker under Microsoft Windows
The i ns ta l l a ti on of OntoBroker i s fa s t a nd ea s y. After s ta rti ng the i ns ta l l a ti on fi l e, the i ns ta l l a ti on proces s i s
i ni ti a ted. In the fol l owi ng, you ha ve to confi rm the prompts i n the wi ndows tha t a ppea r. Before i ns ta l l i ng
OntoBroker, you ha ve to check whether your computer meets the s ys tem requi rements for the recommended
confi gura ti on. Before i ns ta l l i ng OntoBroker, cl os e a l l of the progra ms a nd a ppl i ca ti ons on the computer. The
i ns ta l l a ti on wi za rd wi l l gui de you through the further i ns ta l l a ti on proces s . Duri ng the i ns ta l l a ti on, you wi l l
be a s ked for the KeyFi l e whi ch s houl d be s tored i n the OntoBroker i ns ta l l a ti on fol der.
Note:
Keyfi l es for di fferent vers i ons ca n be put i nto the s a me di rectory ONTOPRISE_LICENSE_HOME.
10
OntoBroker 6.3 Genera l Informa ti on
Unzi p the OntoBroker di s tri buti on i nto a fol der (e.g. /us r/s ha red/ontopri s e/ontobroker),
Copy the l i cens e key fi l e (ob_prof.key.xml ) i nto the s a me fol der.
The s etup proces s i s now fi ni s hed. You s houl d be a bl e to s ta rt OntoBroker us i ng the comma ndl i ne uti l i ti es .
Note:
The i ns ta l l er a utoma ti ca l l y i ns ta l l s the correct runti me dependendi ng on the ta rget ma chi ne's bi t-vers i on.
System Requirements
Application System Requirements
Permi tted opera ti ng s ys tems Wi ndows XP Profes s i ona l
Wi ndows 7
Wi ndows Vi s ta
Wi ndows Server 2003
Li nux (tes ted on SUSE, Debi a n a nd Ubuntu)
Important Notes
Installing JDBC-Driver
For da ta ba s e s chema i mports , a n a ppropri a te JDBC Dri ver for the da ta ba s e ma y be requi red. Whi l e
OntoBroker s upports Ora cl e, MSSQL Server a nd DB2 out of the box, other dri vers , s uch a s MySQL ma y not be
redi s tri buted. If you ha ve purcha s ed a va l i d l i cens e for the dri ver, you ma y confi gure OntoBroker i n the
fol l owi ng wa y:
Copy the da ta ba s e dri ver to [OntoBroker]/l i b (e.g. mys ql -connector-ja va -5.1.5-bi n.ja r)
Afterwa rds wri te the s etti ngs to OntoConfi g.prp:
ExternalDB.OtherDatabase.Driver = com.mysql.jdbc.Driver
ExternalDB.OtherDatabase.ConnectionURL = jdbc:mysql://$host$/$name$
11
OntoBroker 6.3 Genera l Informa ti on
OWL 63
RIF 75
OntoBroker provi des na ti ve s upport for RDF/RDFS a nd OWL. Thi s ma kes OntoBroker a ppl i ca bl e for a wi de
ra nge of s ema nti c a ppl i ca ti ons a nd s cena ri os . It i s pos s i bl e to us e OntoBroker a s a hi gh-performa nce RDF
tri pl e s tore (or qua d s tore), for typi ca l OWL rea s oni ng ta s ks (e.g. cons i s tency checks ) for conjuncti ve queri es
a ga i ns t a n OWL ontol ogy, for hi gh performa nce ObjectLogi c rea s oni ng for eva l ua ti ng a nd debuggi ng rul es . It i s
pos s i bl e to us e di fferent s tora ge s ys tems wi th a l l ontol ogy l a ngua ges . Thi s mea ns tha t you ca n us e the
pers i s tent s tora ge H2 for s tori ng OWL a xi oms , RDF tri pl es a nd ObjectLogi c fa cts a nd rul es .
You ca n us e SPARQL (W3C s ta nda rd for RDF query l a ngua ges ) for executi ng queri es i n combi na ti on wi th a l l
other ontol ogy l a ngua ges (s ee the "Query La ngua ges " cha pter for further deta i l s ). OntoBroker a l s o provi des a
powerful Ja va -ba s ed API whi ch ca n be us ed to open, modi fy a nd s tore ontol ogi es , convert ontol ogy l a ngua ges
(e.g. from OWL to ObjectLogi c) a nd to execute queri es a ga i ns t a n ontol ogy. Thi s API wa s des i gned to be
i ndependent from the ontol ogy l a ngua ge. Thi s ma kes i t ea s y to a cces s OntoBroker from your own
a ppl i ca ti ons a nd to wri te a ppl i ca ti ons whi ch ca n dea l wi th a l l ontol ogy l a ngua ges .
The ontol ogy l a ngua ge ca n be s et i n the OntoConfi g.prp confi gura ti on fi l e of the OntoBroker s erver:
OntologyLanguage = ObjectLogic
or
OntologyLanguage = RDF
or
OntologyLanguage = OWL
12
OntoBroker 6.3 Genera l Informa ti on
13
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
2.3 Configuration
Thi s s ecti on covers s peci fi c confi gura ti on opti ons rel a ted to RDF. For a l l other s etti ngs s uch a s eva l ua ti on
methods or pers i s tency, s ee the ma i n OntoBroker documenta ti on.
If neces s a ry, you ca n a cti va te a ddi ti ona l RDF(S) enta i l ment rul es . There a re two opti ona l groups defi ned to
i nfer i mpl i ci t defi ned cl a s s es a nd/or properti es . The defa ul t s etti ng for both opti ons i s off.
RDF.Infer.Classes = on|off
RDF.Infer.Properties = on|off
Fi na l l y, i f query performa nce i s more i mporta nt tha n s tora ge cons umpti on, a l l of the RDF(S) enta i l ment rul es
ca n be ma teri a l i zed. By defa ul t, ma teri a l i za ti on i s s wi tched off.
MaterializeAxioms = on|off
Materialize.RDF.Entailment.Domain = on|off
Materialize.RDF.Entailment.Range = on|off
Materialize.RDF.Entailment.PropertyTransitivity = on|off
Materialize.RDF.Entailment.PropertyInheritance = on|off
Materialize.RDF.Entailment.ClassInheritance = on|off
Materialize.RDF.Entailment.ClassTransitivity = on|off
Materialize.RDF.Helper.Subclass = on|off
Materialize.RDF.Helper.Subproperty = on|off
Materialize.RDF.Helper.Generic = on|off
Materialize.RDF.Helper.TypeTemp = on|off
Materialize.RDF.Helper.Type = on|off
Materialize.RDF.PropertyDef.ByPredicate = on|off
Materialize.RDF.PropertyDef.ByDomain = on|off
Materialize.RDF.PropertyDef.ByRange = on|off
Materialize.RDF.PropertyDef.BySubpropertySubject = on|off
Materialize.RDF.PropertyDef.BySubpropertyObject = on|off
Materialize.RDF.ClassDef.ByType = on|off
Materialize.RDF.ClassDef.ByDomain = on|off
Materialize.RDF.ClassDef.ByRange = on|off
Materialize.RDF.ClassDef.BySubclassSubject = on|off
Materialize.RDF.ClassDef.BySubclassObject = on|off
14
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
The bes t eva l ua ti on method to choos e i s hi ghl y dependent on the cha ra cteri s ti cs of the gi ven da ta a nd
queri es . The defa ul t s etti ngs s houl d work fi ne for mos t us e ca s es . For further opti mi za ti on, the fol l owi ng
s etti ngs ma y be tes ted a l terna ti vel y:
• Set eva l ua ti on method to Dyna mi c Fi l teri ng 2:
EvaluationMethod = DynamicFiltering2
• Set eva l ua ti on method to Di s juncti ve Ma gi c Set i n combi na ti on wi th bottom-up eva l ua tor Bottom-Up 2:
EvaluationMethod = DisjunctiveMagicSet
BottomUpEva l ua tor = BottomUp2
• Acti va ti on of modul e na mes ground:
ModuleNamesGround = on
Pl ea s e note tha t s ome res tri cti ons a ppl y for concept a nd a ttri bute na mes ground. See the FAQ 24 for more
deta i l s . Note i n a ddi ti on tha t s ome fi l ter expres s i ons a re not bottom-up s a ve. If s uch fi l ter expres s i ons a re
requi red, us e s ome top-down ba s ed eva l ua ti on l i ke Dyna mi c Fi l teri ng 2 s i nce bottom-up eva l ua ti on i s not
pos s i bl e i n s uch a ca s e.
2.4 API
Thi s cha pter gi ves a s hort i ntroducti on on worki ng wi th the OntoBroker Ja va API. Al l ma i n ta s ks l i ke crea ti ng
ontol ogi es a nd runni ng queri es a re covered i n the fol l owi ng expl a na ti ons a nd code fra gments . The s ource
code of thi s exa mpl e i s l oca ted i n RDFDemo.ja va (cl a s s com.ontopri s e.exa mpl es .rdf.RDFDemo) wi thi n the
OntoBroker i ns ta l l a ti on di rectory.
2.4.1 By Example
We s ta rt by i ni ti a l i zi ng the ontol ogy ma na ger, ei ther wi th a l oca l connecti on or to a remote s erver i ns ta nce. In
thi s exa mpl e a l oca l connecti on i s us ed, confi gured for RDF. In a ddi ti on the modul e na mes ground i s
a cti va ted.
Properties properties = new Properties();
properties.setProperty(IConfig.MODULE_NAMES_GROUND, IConfig.ON);
OntologyManager manager = KAON2Manager.newOntologyManager(OntologyLanguage.RDF,
properties);
A new ontol ogy ca n be crea ted us i ng the i ni ti a l i zed ma na ger. The fi rs t a rgument "modul e" i n crea teOntol ogy
equa l s the RDF context or gra ph i denti fi er. Si mpl y s et thi s va l ue to a va l i d a bs ol ute IRI. The s econd a rgument
a l l ows you to s peci fy further opti ons for the new ontol ogy. For our exa mpl e we do not need them a nd s et the
a rgument to nul l .
Ontology ontology = manager.createOntology(module, null);
The crea ted ontol ogy i s empty. There a re s evera l wa ys to a dd new s ta tements , i .e. tri pl es . Let's s ta rt by
i mporti ng the content of a RDF ontol ogy fi l e, here referred to a s "s a mpl e.rdf" i n the current di rectory. In thi s
exa mpl e, a l l of the a ddi ti ona l a rguments of the i mport method a re not requi red.
ontology.importContentsFrom(new File("sample.rdf"), null, null);
New s ta tements ca n be a l s o crea ted us i ng the API. The fol l owi ng l i nes of code s how the cons tructi on of
s evera l RDF terms whi ch a re fi na l l y combi ned to a new RDF s ta tement. Thi s s ta tement i s then a dded to the
ontol ogy.´
KAON2Factory factory = KAON2Manager.factory();
Constant subject = factory.constantIRI("http://www.example.com/#cain");
Constant predicate = factory.constantIRI("http://www.example.com/#name");
Constant object = factory.constantRDFText("Kain", "de");
FPropertyMember stmt = factory.fpropertyMember(subject, predicate, object);
ontology.addAxiom(stmt);
Us i ng Turtl e s ynta x, whi ch i s compa ct a nd ea s y to rea d a nd a l s o a voi ds s ome i s s ues of RDF/XML s eri a l i za ti on,
new s ta tements ca n be i ns erted by executi ng a SPARQL Upda te comma nd.
manager.execute("sparqlUpdate \"\"\"PREFIX : <http://www.example.com/#> "
+ "INSERT DATA { GRAPH <urn:demo#> { :able :age 32; :knows :cain. } }\"\"\"");
15
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
Fi na l l y we query the ontol ogy us i ng SPARQL. Thi s exa mpl e s peci fi es a s i mpl e query i ncl udi ng a fi l ter. The
res ul ts a re pri nted to the cons ol e. For deta i l s on queri es s ee the SPARQL compa ti bi l i ty overvi ew. Non-
s ta nda rd query extens i ons a re a l s o expl a i ned there. For exa mpl e the 'debug' opti on genera tes a more
verbos e output a nd s hows deta i l s of the i nterna l l y us ed rul es a nd query opti mi za ti ons . A qui te ha ndy tool
es peci a l l y for the opti mi za ti on of compl ex queri es . For better l egi bi l i ty, excepti on a nd error ha ndl i ng ha s
been excl uded.
// show results
Term[] buffer = query.tupleBuffer();
Formatting format = ontology.getOntologyFormatting().getDefaultFormatting();
while (!query.afterLast()) {
for (Term term: buffer) {
System.out.print(term.toString(format) + "\t");
}
System.out.println();
query.next();
}
query.close( ) ;
Exa mpl e:
Gi ven the RDF ontol ogy
@prefix : <http://www.example.com/ontology#> .
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> .
:alice :name "Alice" .
:bob :name "Bob" .
a nd the SPARQL query
16
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
PREFIX : <http://www.example.com/ontology#>
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT { ?person vcard:FN ?name }
WHERE { ?person :name ?name }
wi l l produce the res ul ti ng gra ph, repres ented a s tri pl es vi a va ri a bl e bi ndi ngs
$s $p $o
:a l i ce vca rd:FN "Al i ce"
17
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
For more deta i l s , s ee the Ja va Doc del i vered wi th OntoBroker RDF. Pa rti cul a rl y the cl a s s com.ontopri s e.fi l es .
rdf.s ha red.RDFUti l s provi des further us eful RDF rel a ted methods .
xs d:i nt xs d:i nt
xs d:l ong xs d:l ong
xs d:i nteger xs d:i nteger
xs d:byte xs d:deci ma l
xs d:s hort
xs d:deci ma l
xs d:nega ti veInteger
xs d:pos i ti veInteger
xs d:nonNega ti veInteger
xs d:nonPos i ti veInteger
xs d:uns i gnedByte
xs d:uns i gendInt
xs d:uns i gnedLong
xs d:uns i gendShort
18
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
2.6 Inferencing
OntoBroker RDF s upports a confi gura bl e s ub-s et of RDF/RDFS i nferenci ng. As defa ul t a s ub-s et i s choos en to
a chi eve good performa nce. Thi s i ncl udes thes e RDFS rul es
RDFS2: RDF.Enta i l ment.Doma i n
RDFS3: RDF.Enta i l ment.Ra nge
RDFS5: RDF.Enta i l ment.PropertyTra ns i ti vi ty
RDFS7: RDF.Enta i l ment.PropertyInheri ta nce
RDFS9: RDF.Enta i l ment.Cl a s s Inheri ta nce
RDFS11: RDF.Enta i l ment.Cl a s s Tra ns i ti vi ty
RDF.PropertyDef.ByHi era rchy
RDF.Cl a s s Def.ByHi era rchy
i n whi ch the l a s t two rul es i mpl ement a s ub-s et of the a xi oma ti c fa cts covered by the i nterna l concept/
property hi era rchy.
If more deta i l ed control i s requi red i nferenci ng us i ng the hi era rchi es coul d be di s a bl ed a nd s el ecti vel y
(a ddi ti ona l ) rul es s wi tched on/off. Si mpl y a cti va te the confi gura ti on s etti ngs
RDF.Infer.Properties = on
RDF.Infer.Classes = on
a nd the a ddi ti ona l rul es
RDF1: RDF.PropertyDef.ByPredi ca te
RDF.PropertyDef.ByDoma i n
RDF.PropertyDef.ByRa nge
RDF.PropertyDef.BySubpropertySubject
RDF.PropertyDef.BySubpropertyObject
RDF.Cl a s s Def.ByType
RDF.Cl a s s Def.ByDoma i n
RDF.Cl a s s Def.ByRa nge
RDF.Cl a s s Def.BySubcl a s s Subject
RDF.Cl a s s Def.BySubcl a s s Object
ca n be us ed i ns tea d of the i nterna l hi era rchi es .
Al l gi ven rul es ca n be i ncrementa l l y ma teri a l i zed by s etti ng the opti on "Ma teri a l i za ti on.<i denti fi er>" to "on",
e.g.
Materialization.RDF.Entailment.ClassTransitivity = on
19
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
2.7 SPARQL
OntoBroker RDF s upports SPARQL (pronounced "s pa rkl e"), the W3C recommenda ti on for queryi ng RDF da ta .
Thi s cha pter des cri bes deta i l s on the i mpl ementa ti on, compa ti bi l i ty i s s ues a nd extens i ons . If you a re not
fa mi l i a r wi th SPARQL we recommend tha t you fi rs t of a l l rea d the offi ci a l s peci fi ca ti on.
General
Impl i ci t REDUCED mode: Us i ng opti mi zed eva l ua ti on s tra tegi es , a n ea rl y el i mi na ti on of dupl i ca tes i s
i mporta nt. Therefore per defa ul t a l l SPARQL queri es opera te i n REDUCED mode. Thi s mi ght a l s o a ffect the
s el ecti on pa rt of CONSTRUCT a nd DESCRIBE queri es .
Lexi ca l l i tera l va l ue ma tchi ng: As des cri bed i n RDF Compa ti bi l i ty onl y the va l ues , but not thei r ori gi na l
l exi ca l repres enta ti ons a re s tored. Res ul ti ng queri es for l i tera l s l i ke "0001"^^xs d:i nteger wi l l a l wa ys be
tra ns l a ted to "1" of type xs d:i nt.
Ha ndl i ng of unbound va ri a bl es : Thi s fea ture of SPARQL l ogi c i s i mpl emented us i ng a s peci a l NULL
cons ta nt whi ch repres ents a n unbound va ri a bl e. In combi na ti on wi th UNION pa tterns , a va ri a bl e mi ght
be "a ctua l l y bound" wi th NULL, whi ch coul d prevent s ome of the va l i d s ol uti ons found outs i de the UNION
pa ttern.
Defa ul t gra ph: In OntoBroker RDF a l s o the defa ul t gra ph i s l a bel ed by a n i denti fi er (obl :res erved:
defa ul tModul e).
Na mes pa ce prefi xes : Thos e defi ni ti ons a re onl y s upported for a l i mi ted Uni code ra nge (cha ra cters bel ow
0x0300).
Bl a nk nodes i n WHERE cl a us e: If expl i ci tl y na med bl a nk nodes a re us ed i n WHERE cl a us e they a re
ma tched a ga i ns t thos e bl a nk nodes i n the s tore – a nd do not a ct a s va ri a bl es . If the s ta nda rd W3C
s ema nti cs a re requi red, ei ther a n a nonymous bl a nk node or a va ri a bl e ha s to be us ed.
20
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
"compa ti bi l i ty mode" where the va l ue 'error' i s ma pped to 'fa l s e'. Whi l e mos t of the fi l ter expres s i ons
work a s expected, the res ul t wi l l di ffer es peci a l l y for nega ti on of errors (i n SPARQL a nega ti on of a n error
i s a n error, where i n OntoBroker RDF the nega ti on of fa l s e wi l l be true).
Compa ri s on of Bool ea n s ub-expres s i ons , s uch a s (?a < 3) > (4 != ?b) i s not s upported.
XSD type ca s ts a re i mpl emented for xs d:s tri ng, xs d:bool ea n, xs d:da te, xs d:ti me, xs d:da teTi me, xs d:
dura ti on, a s wel l a s the s upported numeri c va l ues xs d:deci ma l , xs d:l ong, xs d:i nteger, xs d:i nt, xs d:doubl e.
For the numeri c convers i ons , pl ea s e cons i der OntoBroker's i mpl ementa ti on of the RDF da ta model .
Extended da te/ti me s upport: For conveni ence da te/ti me va l ues a re a l rea dy ta ken i nto cons i dera ti on i n
compa re opera ti ons .
Queri es us i ng fi l ter expres s i ons a cces s i ng va ri a bl es (not onl y i n the current gra ph pa ttern) ma y not be
eva l ua ted bottom-up. Pl ea s e choos e a n a l terna ti ve eva l ua ti on method s uch a s Dyna mi c Fi l teri ng
i ns tea d.
Ordering
Order expres s i ons : Onl y expres s i ons not returni ng Bool ea n va l ues a re s upported.
CONSTRUCT queries
Cons tructi on pa tterns us i ng bl a nk nodes a re memory-i ntens i ve a nd s houl d onl y be us ed for s ma l l to
medi um res ul t s ets .
Sol uti on modi fi ers wi l l opera te on the res ul t gra ph, not on the i ntermedi a te query res ul ts . See DESCRIBE
bel ow for deta i l s a nd us e ca s es .
DESCRIBE queries
As i t i s up to the SPARQL query proces s or to defi ne des cri pti ons , OntoBroker wi l l des cri be every res ource
by a l l a s s oci a ted properti es , i .e. s ta tements wi th the res ources to des cri be i n s ubject pos i ti on.
Sol uti on modi fi ers for DESCRIBE l i ke orderi ng a re i gnored. Us i ng LIMIT a nd OFFSET modi fi ers the
res ul ti ng gra ph wi l l be s l i ced, but due to mi s s i ng s orti ng the a ctua l s el ecti on mi ght be a rbi tra ry.
However, LIMIT coul d be us ed to res tri ct the res ul ti ng gra ph to a ma xi mum number of s ta tements , for
exa mpl e, for protecti on from deni a l -of-s ervi ce a tta cks whi ch mi ght us e queri es wi th l ow s el ecti vi ty to
return l a rge res ul t s ets .
Update operations
The SPARQL Upda te i mpl ementa ti on i s ba s ed on the current SPARQL Upda te W3C dra ft (14 October 2010),
us i ng the SPARQL 1.0 Query defi ni ti on for the where-cl a us es . Mi nor di fferences i n compa ri s on to the W3C
exa mpl es a nd gra mma r a re expl a i ned i n the fol l owi ng l i nes .
BASE a nd PREFIX defi ni ti ons a l l owed a t the begi nni ng of a n opera ti on s equence a nd s ha red a mong the
opera ti ons , a nd s ubs equent opera ti on-l oca l prefi x defi ni ti ons a re not expected.
21
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
"geoDi s ta nce/2" (coordi na te1, coordi na te2). However, the a s s oci a ted OntoBroker bui l t-i n ha s to i ncrea s e
the a ri ty by one to provi de the return va l ue: "geoDi s ta nce/3" (coordi na te1, coordi na te2, di s ta nce). An
exempl a ry SPARQL query us i ng thi s functi on to fi nd a l l ci ti es wi th di s ta nces l a rger tha n 2000 km:
PREFIX obl: <obl:reserved:>
PREFIX : <http://www.example.com/geo#>
SELECT * WHERE { ?city1 a :City; :location ?l1. ?city2 a :City; :location ?l2.
FILTER (obl:geoDistance(?l1, ?l2) > 2000) }
Any other bui l t-i n type l i ke a ggrega ti ons or connectors ca nnot be us ed i ns i de SPARQL expres s i ons .
Out of the box there a re s evera l bui l t-i ns a va i l a bl e for va ri ous opera ti ons (ma thema ti ca l , s tri ngs , ti me etc.).
Si mpl y extend the query by the keyword OPTIONS (not ca s e s ens i ti ve) a nd a dd a l l of the query opti ons
encl os ed i ns i de a SPARQL s tri ng, s epa ra ted by comma . An exa mpl e:
SELECT * { ?s ?p ?o } OPTIONS "inferOff, debug"
For more deta i l ed i nforma ti on on the query opti ons a nd i nterpreta ti on of the output, s ee the ma i n
OntoBroker documenta ti on.
To veri fy i f the s ervi ce i s s ta rted you ca n a cces s http://localhost:8267/services whi ch provi des a n
overvi ew of a l l depl oyed REST or REST-s tyl e (a nd SOAP) s ervi ces . Addi ti ona l l y vi a http://localhost:8267/
services/sparql?_wadl a Web Appl i ca ti on Des cri pti on La ngua ge (WADL)-ba s ed s peci fi ca ti on of the
s ervi ce pa ra meters a nd s upported MIME types ca n be deri ved. Pl ea s e be a wa re tha t thi s genera ted
des cri pti on does not refl ect every deta i l , e.g. pa ra meter qua l i fi ers l i ke requi red a nd repea ti ng a re not
i ncl uded.
For tes ti ng a nd debuggi ng purpos es the debug mode mi ght be us ed. It i s a cti va ted ei ther by di rectl y a cces s i ng
the s ervi ce wi thout a ny a rguments or expl i ci tl y s etti ng the pa ra meter debug to true. The l i ghtwei ght HTML
ba s ed UI a l l ows you to s wi tch between upda te a nd query mode. For queri es the URI-res ul ts a re l i nked to
ba s i c SPARQL queri es thus s upporti ng a ba s i c na vi ga ti on through the l oa ded da ta . Both the query a nd upda te
s ervi ces a re documented i n deta i l i n the next s ecti ons .
22
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
Ontobroker ca n be expos ed a s s uch a n LOD endpoi nt. Together wi th i ts i ntegra ti on ca pa bi l i ti es thi s provi des
a l a rge a mount of pos s i bi l i ti es to bri ng da ta i nto the l i nked open da ta cl oud.
2.8.1 Queries
To i nvoke the query s ervi ce, a t l ea s t one query ha s to be s peci fi ed. For exa mpl e, us i ng the defa ul t endpoi nt
confi gura ti on the query
SELECT * {?s ?p ?o}
wi l l res ul t i n the encoded URI
http://localhost:8267/services/sparql/query?query=SELECT%20*%20%7B?s%20?p%20?o%7D
Further exa mpl es a re a va i l a bl e a t W3C SPARQL Protocol HTTP Exa mpl es .
More techni ca l l y, the s ervi ce s upports both GET a nd POST reques ts . An overvi ew of a l l of the pa ra meters i s
provi ded i n the fol l owi ng ta bl e:
defa ul t-gra ph-uri xs d:a nyURI Expl i ci tl y s et defa ul t gra phs (0..n)
debug xs d:bool ea n Swi tch to debug mode i f true, i .e. s how HTML ba s ed UI (opti ona l )
If both by SPARQL query a nd vi a a rguments defa ul t-gra ph-uri or na med-gra ph-uri gra phs a re s el ected, the
a rgument's defi ni ti ons a re us ed.
The query res ul t wi l l be returned i n di fferent forma ts , dependi ng on the query form a nd HTTP content
negoti a ti on. In a l l ca s es UTF-8 i s us ed a s encodi ng.
SELECT Va ri a bl e bi ndi ngs SPARQL Query Res ul ts XML Forma t (a ppl i ca ti on/s pa rql -
res ul ts +xml ) a s defa ul t or JSON (a ppl i ca ti on/js on)
ASK Bool ea n va l ue
2.8.2 Updates
One or more upda te opera ti ons ha s to be s peci fi ed for i nvoki ng the upda te s ervi ce. For exa mpl e, the
opera ti on
LOAD <http://www.w3.org/1999/02/22-rdf-syntax-ns.rdf>
wi l l res ul t i n the GET-encoded URI
http://localhost:8267/services/sparql/update?update=LOAD%20%3Chttp://www.w3.
org/1999/02/22-rdf-syntax-ns.rdf%3E
Bes i des the upda te pa ra meter, the debug opti on ca n be s peci fi ed. The fol l owi ng ta bl e s hows a n overvi ew of
23
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store
upda te xs d:s tri ng The SPARQL Upda te opera ti on(s ) (requi red)
debug xs d:bool ea n Swi tch to debug mode i f true, i .e. s how HTML ba s ed UI (opti ona l )
The res ul t i s returned a s pl a i n text. Ei ther wi th a s i mpl e s ta tus mes s a ge tha t everythi ng went fi ne, i .e. a l l
opera ti ons ha ve been executed wi thout a n error, or a n des cri pti on of the error tha t occurred.
2.9 FAQ
Wha t i s the di fference between RDFTerm-equa l a nd s a meTerm?
Compa ri ng two terms by equa l i ty (opera tor '=') checks for va l ue equa l i ty, e.g. "1.0"^^xs d:doubl e i s equa l to
"1"^^xs d:i nt. s a meTerm i n contra s t checks for i denti ty, e.g. "1.0"^^xs d:doubl e i s di fferent from "1"^^xs d:i nt.
Pl ea s e note tha t due to the i mpl i ci t type ca s ti ng e.g. "1"^^xs d:l ong a nd "1"^^xs d:i nt wi l l be i denti ca l (a nd
of cours e equa l too). Dependi ng on your da ta , i f the check s a meTerm i s s uffi ci ent, a huge performa nce
benefi t mi ght be the res ul t. Es peci a l l y i n combi na ti on wi th a pers i s tent da ta model s a meTerm i s much
more effi ci ent.
The da ta s et i s defi ned by the query us i ng a combi na ti on of FROM a nd FROM NAMED. If one or more na med
gra phs a re s peci fi ed but no defa ul t gra ph the defa ul t gra ph i s empty. If onl y one or more defa ul t gra phs
a re gi ven but no na med gra phs the s et of na med gra phs i s empty. Fi na l l y, i f nei ther a defa ul t nor na med
gra phs a re s peci fi ed the defa ul t da ta s et i s us ed. Thi s conta i ns the current, i .e. queri ed, ontol ogy a s a
defa ul t gra ph a nd a l l other gra phs a s na med gra phs .
ObjectLogi c s upport?
Dependi ng on the chos en na mes ground confi gura ti on not a l l of the SPARQL/RDF fea tures a re a va i l a bl e. A
s a fe opti on wi thout a ny res tri cti on i s to a cti va te modul e na mes ground. Thi s mi ght i ncrea s e the overa l l
performa nce. If you choos e concept na mes ground or a ttri bute na mes ground the mergi ng of the defa ul t
gra ph i n SPARQL queri es i s not s upported. In a ddi ti on, no s ub-properti es ma y be us ed for a ttri bute na mes
ground. Thos e s i ngl e res tri cti ons a l s o a ppl y for the combi na ti on of di fferent na mes ground s etti ngs .
24
OntoBroker 6.3 OntoBroker GUI
3 OntoBroker GUI
The OntoBroker Admi ni s tra ti on Cons ol e i s a n ea s y to us e gra phi ca l us er i nterfa ce for confi guri ng a nd
executi ng OntoBroker a s a s erver a nd s erves a s a cl i ent for demons tra ti on a nd tes t purpos es . Thi s cha pter
des cri bes how to us e the OntoBroker Admi ni s tra ti on Tool .
25
OntoBroker 6.3 OntoBroker GUI
"Startup" tab
The us er i nterfa ce of the Admi ni s tra ti on Cons ol e cons i s ts of 5 a rea s i n the Sta rtup ta b:
Nr Area Description
.
1 Configuration You ca n us e the defa ul t va l ues or l oa d your own confi gura ti on fi l e (s ee OntoConfi g.prp
a t the OntoBroker home di rectory).
2 Startup Mode Wi thi n the s ta rtup mode OntoBroker ca n be l a unched i n defa ul t mode or i t ca n ei ther be
confi gured a s a col l a bora ti on s erver, or a cces s i ng Remote API.
3 Startup OntoBroker i s a l s o s ta rted a s a ‘WebServi ce’ , i f ‘ WebServi ce’ i s a cti va ted. If ‘Si l ent’ i s
Options a cti va ted there wi l l be no output to the OntoBroker cons ol e. The Web cons ol e i s the
defa ul t va l ue. For more i nforma ti on on the Webcons ol e cl i ck here 36
4 Ontology files In the Ontol ogy fi l es -a rea , fi l es of fol ders ca n be a dded wi th whi ch OntoBroker s houl d
s ta rt. Thes e fi l es mus t conta i n fa cts a nd rul es i n a n i nput forma t l i ke ObjectLogi c, RDF
(S), OWL or N-Tri pl e (n3, nt).
5 Startup Wi thi n the s ta rtup a rea , you ca n confi gure the hea p s i ze of OntoBroker a nd JVM
a rguments . The confi gura ti on ca n be s a ved by cl i cki ng <Sa ve a s .cmd fi l e> i n the
confi gura ti ons -fi el d. Furthermore, you ca n s ta rt or fi ni s h OntoBroker here.
26
OntoBroker 6.3 OntoBroker GUI
Nr Area Description
.
1 Connection After the confi gura ti on i s compl ete, the port-number (s ta nda rd port i s <2267>) on whi ch
OntoBroker s houl d run ha s to be chos en. The IP-a ddres s ca n a l s o be s peci fi ed.
27
OntoBroker 6.3 OntoBroker GUI
Nr. Description
1 Ontology Management
2 Command Output
28
OntoBroker 6.3 OntoBroker GUI
A very us eful functi on i s the Available commands button. One cl i ck provi des a l i s t of a l l comma nds . Sel ect a
comma nd a nd copy a nd pa s te i t:
29
OntoBroker 6.3 OntoBroker GUI
The Info functi on s hows a l l of the i mporta nt i nforma ti on a bout a runni ng OntoBroker i ns ta nce a nd the l oa ded
ontol ogy:
30
OntoBroker 6.3 OntoBroker GUI
31
OntoBroker 6.3 OntoBroker GUI
The cons ol e wi ndow s hows a ny i nforma ti on a bout the s ta rti ng OntoBroker (e.g. confi gura ti on).
After OntoBroker ha s been s ta rted, a comma nd l i ne box s houl d a ppea r (s ee bel ow). After a l l of the fi l es
ha ve been s ucces s ful l y l oa ded, the OntoBroker Admi ni s tra ti on Tool s hows the mes s a ge <OntoBroker up
a nd runni ng...>.
32
OntoBroker 6.3 OntoBroker GUI
33
OntoBroker 6.3 OntoBroker GUI
34
OntoBroker 6.3 OntoBroker GUI
2. Pres s "Connect".
The OntoBroker Webcons ol e i s s ta rti ng on l oca l hos t on port 8627:
35
OntoBroker 6.3 OntoBroker GUI
"Query" tab
Wi thi n the webcons ol e, there a re s evera l opti ons for ha ndl i ng a query:
36
OntoBroker 6.3 OntoBroker GUI
"Command" tab
On the Command ta b, comma nds ca n be executed.
A l i s t of a l l of the s erver comma nds ca n be found i n the rel eva nt cha pter.
37
OntoBroker 6.3 OntoBroker GUI
"Config" tab
On the Config ta b a l l of the OntoBroker s etti ngs a re di s pl a yed a t a gl a nce. Cha nge your s etti ngs i n the
OntoConfi g.prp.
38
OntoBroker 6.3 OntoBroker GUI
In the next s tep you get i nforma ti on on the Web s ervi ce methods , the endpoi nt a ddres s a nd a l i nk to the
WSDL.
1. Sta rt the OntoBroker GUI by cl i cki ng on: Start -> Programs -> OntoBroker -> OntoBroker Administration Console.
2. From the top l evel menu s el ect: Tool -> Convert ontologies.
39
OntoBroker 6.3 OntoBroker GUI
After a ddi ng the ontol ogy, ba s i c i nforma ti on on the ontol ogy i s di s pl a yed:
40
OntoBroker 6.3 OntoBroker GUI
41
OntoBroker 6.3 OntoBroker GUI
The ontol ogy wi l l be converted a nd s a ved i n the s peci fi ed fol der wi th the chos en fi l ena me.
Note:
If the convers i on ca us es probl ems or i nforma ti on gets l os t, you wi l l be i nformed i n the Mes s a ges wi ndow
a t the bottom end of the convers i on tool .
42
OntoBroker 6.3 OntoBroker GUI
43
OntoBroker 6.3 Stora ge Sys tems
4 Storage Systems
A s tora ge s ys tem i s the da ta s tructure where the fa cts a nd rul es of a n ontol ogy a re s tored. OntoBroker ha s
three di fferent s tora ge s ys tems :
RAM.AVL.Pa cked 169
H2 273
RAM.TS
The s tora ge pa ra meter ca n a l s o be s et to the va l ue RAM.choos e. In thi s ca s e the OntoBroker s el ects the bes t
RAM da ta model i ts el f. Ea ch s ys tem ha s i ts own s trengths a nd uni que fea tures . The fol l owi ng s ecti on gi ves a
s hort overvi ew of thes e s tora ge s ys tems .
RAM.AVL.Packed
Thi s i s the new s ta nda rd RAM da ta model whi ch i s ti ghtl y pa cked i n order to reduce the memory. It us es ha s h
i ndi ces for pri ma ry i ndi ces , tri es for s econda ry i ndi ces a nd pa cked AVL trees for s econda ry s orted i ndi ces .
Thi s s tora ge s ys tem i s es peci a l l y opti mi zed for the eva l ua ti on methods BottomUp2 a nd Dyna mi cFi l teri ng2.
Note:
Thi s i s the fa s tes t a nd mos t memory-effi ci ent da ta model for the i nference s erver.
H2
OntoBroker s hi ps wi th a pers i s tent s tora ge s ys tem (we currentl y us e the H2 SQL engi ne). Thi s pers i s tent
s tora ge i s embedded i n OntoBroker, s o i t i s very ea s y to s etup OntoBroker wi th i t. Fa cts a nd rul es a re s tored
pers i s tentl y, i .e. OntoBroker ca n be res ta rted wi thout the need to rel oa d the ontol ogi es .
In order to s ta rt OntoBroker wi th thi s s tora ge s ys tem s et
Storage=H2
i n OntoConfi g.prp.
RAM.TS
A new memory-effi ci ent RAM model .
In order to s ta rt OntoBroker wi th thi s s tora ge s ys tem s et
Storage=RAM.TS
i n OntoConfi g.prp. Thi s s tora ge opti on wi l l s tore tupl es i n a compa ct wa y. The new hi gh-performa nce bottom-
up eva l ua tor (BottomUp3) wi l l onl y work wi th RAM.TS.´
Note:
It i s recommended to s et EvaluationMethod=choose a nd BottomUpEvaluator=choose when us i ng
thi s s tora ge opti on. Note tha t e.g. EvaluationMethod=DynamicFiltering2 wi l l work much s l ower wi th
Storage=RAM.TS tha n wi th Storage=RAM.AVL.Packed.
44
OntoBroker 6.3 Da ta Integra ti on
5 Data Integration
Bes i des s ervi ng a s a common communi ca ti on l a ngua ge a nd repres enti ng expert knowl edge, ontol ogi es s erve
a s a n i ntegra ti on mea ns of di fferent l ega cy s ys tems . The ontol ogy i s us ed to rei nterpret gi ven i nforma ti on
s ources i n a common l a ngua ge a nd thus provi de a common a nd s i ngl e vi ew of di fferent da ta s ources . An
ontol ogy ca n col l ect di fferent s ources a nd i ntegra te them i n a common l ogi ca l model . Thi s goes fa r beyond
jus t bui l di ng connectors between a ppl i ca ti ons . The goa l of i ntegra ti on i s to cons ol i da te di s tri buted
i nforma ti on i ntel l i gentl y, free of redunda ncy a nd provi di ng us ers a nd a ppl i ca ti ons wi th s i mpl e a cces s to
i nforma ti on wi thout cons i deri ng the underl yi ng da ta s tructure or s ys tem.
Supported externa l Da ta ba s es :
Mi cros oft SQL Server 2000, 2005 a nd 2008
Ora cl e 10g a nd 11g
Ora cl e Ti mes Ten i n-memory da ta ba s e 11g
Ora cl e Ti mes Ten i n-memory da ta ba s e ca che 11g
DB2 9.0 a nd 9.5
other JDBC dri vers ca n be embedded by confi gura ti on
SQLExecute
You ca n crea te your own db ma ppi ng rul es , us i ng the s ql execute predi ca te:
?X:"Person"@_defaultModule :- _sqlexecute("SELECT colname FROM tblname",[?
X],"mydbconnection").
NOTE: There mus t be a fa ct s tored i n a n l oa ded ontol ogy defi ni ng the connecti on deta i l s of
"mydbconnecti on", e.g:
_dbaccessuserdata("mydbconnection",
"oracle","databasename","localhost:1521","user","pwd").
For more i nforma ti on s ee the bui l t-i n 227 “_dba cces s us er”.
MS SQL Server
The fol l owi ng us er pri vi l eges a re requi red:
Sel ect
Ins ert
Crea te ta bl e
Drop ta bl e
The tempdb da ta ba s e i s us ed. It i s neces s a ry tha t the da ta ba s e a nd the tempdb ha ve the s a me col l a ti on.
45
OntoBroker 6.3 Da ta Integra ti on
Oracle
The fol l owi ng us er pri vi l eges a re requi red:
Sel ect
Ins ert
Crea te ta bl e
Drop ta bl e
If you don´t ha ve wri te a cces s to the s chema , proceed i n the fol l owi ng wa y:
1. Crea te a new us er.
2. Gra nt wri ti ng a cces s to thi s new us er on hi s own s chema .
3. Gra nt jus t rea d a cces s to thi s us er on the s chema wi th da ta .
4. Logi n wi th thi s new us er when doi ng a DB s chema i mport i n OntoStudi o.
5. Choos e the s chema wi th da ta a nd i mport the ta bl es .
DB2
The fol l owi ng us er pri vi l eges a re requi red:
Sel ect
Ins ert
Crea te ta bl e
Drop ta bl e
Us e on us er tempora ry ta bl es pa ce (for Vers i on DB2 8)
You need a us er tempora ry ta bl es pa ce for Vers i on DB2 8.
5.2 Optimization
ShrinkDBAccess 171 , SQLRewriter
Acces s to the da ta ba s e wi l l be opti mi zed whi l s t executi ng a query: _dba cces s us er/3 l i tera l s a re rewri tten i n a
wa y s o tha t onl y the requi red col umns a re s el ected. Furthermore, the dba cces s us er l i tera l s a re combi ned
wi th s ome bui l t-i ns i n a SQL query s o tha t there a re s ome res tri cti ons .
Exa mpl e:
?- _dbaccessuser("projects",F(id,VAR1,project,VAR1),"mydbconnection") and equal
(VAR1,"myproject").
wi l l be rewri tten
?- _sqlexecute("select id, project from projects where project =’myproject’",[?VAR1,?
VAR2],"mydbconnection").
It i s a l s o pos s i bl e to combi ne mul ti pl e _dba cces s us er/3 l i tera l s . _s ql execute/3 l i tera l s a re not opti mi zed.
You ma y encounter performa nce probl ems when dba cces s us er l i tera l s a re not executed correctl y (e.g.
needl es s col umns a re s el ected, dba cces s us er l i tera l s a re executed wi thout res tri cti ons ). For a deta i l ed
a na l ys i s you ca n turn on the SQL tra ci ng.
You ma y a l s o try out i f cha ngi ng s ome of the fol l owi ng s wi tches s i gni fi ca ntl y i mproves the performa nce:
Other eva l ua ti on methods
Us e na mes ground s wi tches : CNG, ANG, MNG on/off.
Us i ng StrongUnfol der (ca n a l s o be us ed i f you onl y us e a coupl e of rul es )
Eva l ua ti on method Dyna mi cFi l teri ng2 wi th ANG=on i s often a good choi ce.
46
OntoBroker 6.3 Da ta Integra ti on
SuppressNull
Note:
There wa s a bugfi x on Suppres s Nul l ! Thi s bugfi x ca n cha nge the beha vi or of ol d ontol ogi es wi th db
ma ppi ng!
id name
1 a
2 nul l
R ule:
p(?X) :- _dbaccessuser("test", F(ID,?X,NAME,?Y), "connectiondatasource").
?X
1
?X
The s econd row (2, nul l ) i s not s el ected now beca us e the NAME i s nul l . For getti ng the ol d res ul t you s houl d
cha nge the rul e a s fol l ows :
p(?X) :- _dbaccessuser("tblname", F(ID,?X), "connectiondatasource").
Res ul t:
47
OntoBroker 6.3 Da ta Integra ti on
1,B 1,B
2,nul l 2,nul l
query - tupl e ca che i s removed a fter the query executi on. Thi s i s the defa ul t va l ue for thi s opti on for a l l
connectors i n OntoStudi o a nd for the WebServi ce connector i n Ontobroker.
unlimited - tupl e ca che i s not removed a fter the query executi on a nd ca n be us ed for the next query. Thi s
opti on i s better for performa nce a nd s houl d a l wa ys be us ed i f a da ta ba s e won't be upda ted a l ot. The ca che
upda te s houl d be done ma nua l l y (s ee "Cl ea r connector ca che comma nd"). Thi s i s the defa ul t va l ue for thi s
opti on i n OntoBroker for a l l of the connectors except for the WebServi ce connector.
Exa mpl es :
Da ta ba s e connector:
clear_connector_cache [_host->"data",_port->1521,_database->"orcl11",_user-
>"testuser",_table->"tblname"]
The ta bl e i s opti ona l ; i f no hos t i s defi ned, the l oca l hos t wi l l be us ed.
5.6 MergeImports
If the MergeImports pa ra meter i s s et to "on" i n the OntoConfi g.prp, i mported ontol ogi es a re di rectl y merged
i nto the i mporti ng root ontol ogy. Thi s mea ns tha t the i mported ontol ogi es a re not a va i l a bl e a s s epa ra te
ontol ogi es a s for OntoStudi o.
Exa mpl e
To a cti va te the MergeImports s wi tch, s et i n the OntoConfi g.prp
MergeImports = on
48
OntoBroker 6.3 Da ta Integra ti on
As s ume tha t you ha ve three ontol ogi es A,B, a nd C. A i mports B a nd B i mports C. Then, a fter l oa di ng you ha ve
onl y one ontol ogy A' (cons i s ti ng of rul es a nd fa cts from A,B, a nd C).
Note 1:
The fl a g i nfl uences onl y the l oa di ng proces s on OntoBroker s ta rt (or rel oa d comma nd).
Note 2:
The MergeImports fl a g ca nnot be us ed together wi th project fi l es .
The Ontology
The ba s e ontol ogy very s trongl y rel i es on pa rts whi ch a re a rra nged i n a pa rt-of hi era rchy a nd thei r properti es .
The i ns ta nces , i .e. concrete va l ues a re mos t often ga i ned from the pa rts l i s t i n the l ega cy s ys tems .Our
ontol ogi es a re repres ented i n ObjectLogi c. Speci fi c ba s i c concepts a re repres ented a s concepts i n ObjectLogi c
a nd a re a rra nged i n a n i s a -hi era rchy. Concepts ma y be des cri bed by a ttri butes a nd rel a ti ons hi ps to other
concepts .
component[
has_part {0:*} *=> component,
is_part {0:*} *=> component,
horsepower {0:1} *=> _integer].
// instances and relations
tdi_engine:component.
valve2:component.
pump3:component.
tdi_engine[
has_part->valve2,
has_part->pump3,horsepower->340].
//rules
@{isPart} ?Y[is_part->?X] :- ?X[has_part->?Y].
//queries
@{allComponents} ?- ?X:component.
In thi s exa mpl e we ha ve defi ned a component a s a ba s i c concept. A component ha s a rel a ti ons hi p ha s _pa rt
to a nother component a nd a n a ttri bute hors epower. Then we crea te a n i ns ta nti a ti on of a component
tdi _engi ne bei ng a s peci fi c engi ne. Concrete i ns ta nces va l ve2, pump3 a re gi ven for concept component. A rul e
i s us ed to des cri be the i nvers i ty of ha s _pa rt a nd i s _pa rt. Wi th a query we a s k for a l l of the components i n the
model . OntoBroker, our rea s oni ng s ys tem, provi des the mea ns for effi ci ent rea s oni ng i n ObjectLogi c.
OntoBroker performs a mi xture of forwa rd a nd ba ckwa rd cha i ni ng ba s ed on the dyna mi c fi l teri ng a l gori thm to
compute (the s ma l l es t pos s i bl e) s ubs et of the model for a ns weri ng the query. Duri ng forwa rd cha i ni ng not
49
OntoBroker 6.3 Da ta Integra ti on
onl y s i ngl e tupl es of va ri a bl e i ns ta nti a ti ons but s ets of s uch tupl es a re proces s ed. It i s wel l -known tha t s et-
ori ented eva l ua ti on s tra tegi es a re much more effi ci ent tha n tupl e ori ented ones . The s ema nti cs for a s et of
ObjectLogi c s ta tements i s then defi ned by a tra ns forma ti on proces s of ObjectLogi c i nto norma l l ogi c (Horn
l ogi c wi th nega ti on) a nd the wel l -founded s ema nti cs for the res ul ti ng s et of fa cts a nd rul es a nd a xi oms i n
norma l l ogi c.
An excerpt of tha t ontol ogy i s s hown i n a pa rt-of vi ew i n our tool OntoStudi o. For exa mpl e, i t s hows tha t a
gea r i s pa rt of a ca r a nd the s wi tchi ng l ever i s a pa rt of the gea r. For the motor s ome a ttri butes s uch a s
ma xi mum power, type, a nd s o on a re s hown. An ontol ogy wi thout rul es des cri bes onl y s i mpl e rel a ti ons hi ps
between concepts l i ke a pa rt i s a pa rt of a nother pa rt, a pa rt i s connected to a nother pa rt, a nd s o on. More
compl ex rel a ti ons hi ps ha ve to be des cri bed by rul es a nd cons tra i nts .
50
OntoBroker 6.3 Da ta Integra ti on
The da ta ba s e ma ppi ng i mports the ta bl e engi ne a s a concept, col umns i d, a bs ol ute_power, fuel ,
vol ume_fl ow a nd engi ne_type a s a ttri butes . Thi s mea ns tha t every row i n the da ta ba s e corres ponds to one
object i n the ontol ogy. OntoStudi o a utoma ti ca l l y crea tes a connecti on to the da ta ba s e by the dba cces s us er-
connector (there a re va ri ous connectors to i nforma ti on s ources a va i l a bl e). Thi s bui l t-i n a utoma ti ca l l y crea tes
a uni que object ID. It i s us ed i n a rul e whi ch defi nes the a cces s a nd the ma ppi ng to the ontol ogy:
@{mappingRule}
?V_ID:Engine[ID->?V_ID, absolute_power->?V_ABSOLUTE_POWER, fuel->?V_FUEL,
volume_flow->?V_VOLUME_FLOW, engine_type->?V_FUEL_TYPE]
:-
_dbaccessuser("engine",
F( "id", ?V_ID, "absolute power", ?V_ABSOLUTE_POWER, "fuel", ?V_FUEL
"volume_flow", ?V_VOLUME_FLOW, "engine_type", ?V_ENGINE_TYPE),
"mydbconnection").
Ontology Mappings
After ha vi ng i mported the da ta ba s e s chema , the res ul t ontol ogy ca n be ma pped wi th a nother ontol ogy. Bel ow
you ca n s ee how a concept-to-concept ma ppi ng connects the concept engi ne to the concept motor a nd,
a ddi ti ona l l y, a n a ttri bute-to-a ttri bute ma ppi ng from i d i n the da ta ba s e ontol ogy to na me i n the new
ontol ogy.
51
OntoBroker 6.3 Da ta Integra ti on
Another i mporta nt ma ppi ng type i s the ma ppi ng of a ttri butes to concepts . Thi s res ul ts i n the a ttri bute va l ue
bei ng us ed a s a uni que ID for a n ontol ogy i ns ta nce. For exa mpl e, ma ppi ng the ID of engi ne to the concept
motor crea tes a n object for every di fferent ID.
52
OntoBroker 6.3 Da ta Integra ti on
Conclusion
In a rea l -l i fe i ndus tri a l project, vi z. i n the a utomoti ve i ndus try a t a ca r ma nufa cturer, we ha ve s hown tha t
ontol ogi es ma y very wel l be us ed to enha nce bus i nes s proces s es a nd to i ntegra te di fferent i nforma ti on
s ources . In our ca s e the ontol ogy repres ents knowl edge a bout rel a ti ons hi ps between di fferent pa rts whi ch
ma y a utoma ti ca l l y be expl oi ted i n confi guri ng tes t ca rs . Thi s reduces the communi ca ti on effort between the
mecha ni ca l engi neers , a nd reduces the error ra te i n confi guri ng tes t ca rs . For thi s ta s k the ontol ogy i s
a tta ched to the l ega cy s ys tems of the ma nufa cturer a nd thus a cces s es up-to-da te i nforma ti on a bout pa rts
a nd confi gura ti ons . We ha ve s hown tha t our ontol ogy engi neeri ng envi ronment OntoStudi o s upports not onl y
the comforta bl e devel opment of ontol ogi es but, wi th the i ntegra ted ma ppi ng tool OntoMa p, a l s o a n ea s y to
l ea rn tool for a tta chi ng ontol ogi es to di fferent i nforma ti on s ources . Our Sema nti cGui de i s ba s ed on our
ontol ogy run-ti me envi ronment a nd i nference engi ne OntoBroker whi ch i s ba s ed on ObjectLogi c. Thi s
s ema nti c gui de a ccel era tes the confi gura ti on of tes t ca rs a t our cus tomer a nd hence a l s o a ccel era tes the
devel opment of new ca rs . In the end, thi s reduces ti me-to-ma rket.
ARRAY -
BIGINT INTEGER
BINARY -
BIT BOOLEAN
BLOB -
BOOLEAN BOOLEAN
CHAR STRING
CLOB -
DATALINK -
53
OntoBroker 6.3 Da ta Integra ti on
DATE DATE
DECIMAL DECIMAL
DISTINCT -
DOUBLE DOUBLE
FLOAT DOUBLE
INTEGER INT
JAVA_OBJECT -
LONGNVARCHAR STRING
LONGVARBINARY -
NCHAR STRING
NCLOB -
NULL -
NUMERIC DECIMAL
NVARCHAR STRING
OTHER -
REAL DECIMAL
REF -
ROWID -
SMALLINT INT
SQLXML -
STRUCT -
TIME TIME
TINYINT INT
VARBINARY -
VARCHAR -
54
OntoBroker 6.3 Da ta Integra ti on
Area Description
Area Description
Input pa ra meter ma p The concrete i nput pa ra meter va l ues a re dependi ng on the webs ervi ce.
["Parameter name"->"value"]
Output ma p Thi s ma p conta i ns the res ul ts of the web s ervi ce ca l l . The concrete s tructure
depends on the web s ervi ce. Us e bui l t-i ns l i ke _memberByPa th/3 or
_ma p2Ta bl e/4 to extra ct va l ues . For further i nforma ti on a bout ma p da ta type cl i ck
here .
Exa mpl e Youmust download the secured wsdl file and provide the local
path to the downloaded file in the query!
?- _webserviceAccess([_wsdl ->"http://weatherservicename/
WeatherForecastSoap?wsdl",
_method->"GetWeatherByPlaceName"], ["PlaceName"->"Karlsruhe"],?
Z).
Syntax
Arguments for _restWebserviceAccess/4:
_restWebserviceAccess(<service>, [invocation args], [service args], ?result)
55
OntoBroker 6.3 Da ta Integra ti on
Caching
The ca chi ng pol i cy i s s et vi a s ta nda rd (SOAP) Web-s ervi ce connector confi gura ti on. To expl i ci tl y cl ea r the ca che
the "cl ea r connector ca che" comma nd wi th a ca che key l i ke.
[_connector->_restWebserviceConnector, _service-><...>]
ha s to be ca l l ed. Pl ea s e repl a ce the el l i ps i s wi th the a ctua l s ervi ce IRI i denti fyi ng the REST web-s ervi ce.
Examples
A few exa mpl es to demons tra te the us a ge of the REST Web-s ervi ce Connector.
@{options[outorder(?title, ?url)]}
?- _restWebserviceAccess(<http://ajax.googleapis.com/ajax/services/search/web>, [->],
["q"->"House", "v"->"1.0", "hl"->"en"], ?jr) and ?jr[_memberByPath(_path
("responseData", "results"))->?results[_member->?result]] and ?result[_memberAt
("unescapedUrl")->?url, _memberAt("titleNoFormatting")->?title].
wi l l return the res ul t
title url
"FOX Broa dca s ti ng Compa ny - Hous e TV Show - Hous e TV Seri es - "http://www.fox.com/hous e/"
Hous e ..."
"FOX Broa dca s ti ng Compa ny - Hous e TV Show - Hous e TV Seri es - "http://en.wi ki pedi a .org/wi ki /Hous e_
Hous e ..." (TV_s eri es )"
"Uni ted Sta tes Hous e of Repres enta ti ves , 112th Congres s , 1s t "http://www.hous e.gov/"
Ses s i on"
Another exa mpl e mi ght be checki ng the popul a ri ty of words , e.g. compa ri ng "a bs orbti on" wi th "a bs orpti on"
p("absorption").
p("absorbtion").
@{options[outorder(?word, ?count), sort(desc(?count))]}
?- p(?word) and _restWebserviceAccess(<http://ajax.googleapis.com/ajax/services/
search/web>, [->], ["q"->?word, "v"->"1.0", "hl"->"en"], ?jr) and ?jr[_memberByPath
(_path("responseData", "cursor", "estimatedResultCount"))->?cs] and _int[_toType(?
cs)->?count].
The res ul t s hows tha t "a bs orpti on" i s fa r more popul a r, whi ch mi ght i ndi ca te i t i s orthogra phi ca l l y the ri ght
va ri a nt
word count
56
OntoBroker 6.3 Da ta Integra ti on
?- _restWebserviceAccess(<http://ajax.googleapis.com/ajax/services/search/books>, [-
>], ["v"->"1.0", "rsz"->"small", "q"->"Thyroid"], ?jr) and ?jr[_memberByPath(_path
("responseData", "results"))->?books[_member->?book]] and ?book[_memberAt("title")->?
title, _memberAt("authors")->?authors, _memberAt("bookId")->?isbn].
Hi nt: To get more tha n the s ta nda rd ma xi ma l four s ea rch res ul ts cha nge the a rgument rsz from small to
large. Thi s wi l l return up to ei ght res ul ts . Ha ve a l s o a l ook a t the offi ci a l API documenta ti on for a ddi ti ona l
a rguments of the book s ea rch s ervi ce.
The ta bl e bel ow s hows the res ul ts :
"M. Sa ra Ros entha l " "The thyroi d s ourcebook for women" "ISBN0071441611"
DBpedia
Sea rchi ng DBpedi a for the ma jor ci ti es i n Ba den-Württemberg, us i ng the SPARQL query
PREFIX : <http://dbpedia.org/ontology/> SELECT ?name, ?population {?town a :Town; :
federalState <http://dbpedia.org/resource/Baden-W%C3%BCrttemberg>; :populationTotal ?
population; <http://www.w3.org/2000/01/rdf-
schema#label> ?name . FILTER (lang(?name)='en') } ORDER BY DESC(?population) LIMIT 5
wi l l res ul t i n the OL query
@{options[outorder(?city,?population)]}
?- _restWebserviceAccess(<http://dbpedia.org/sparql>, [_mime->"application/sparql-
results+json"], ["query"->"PREFIX : <http://dbpedia.org/ontology/> SELECT ?name, ?
population {?town a :Town; :federalState <http://dbpedia.org/resource/Baden-W%C3%
BCrttemberg>; :populationTotal ?population; <http://www.w3.org/2000/01/rdf-
schema#label> ?name . FILTER (lang(?name)='en') } ORDER BY DESC(?population) LIMIT
5"], ?jr) and ?jr[_memberByPath(_path("results", "bindings"))->?results[_member->?
row]] and ?row[_memberByPath(_path("name", "value"))->?city, _memberByPath(_path
("population", "value"))->?popStr] and _int[_toType(?popStr)->?population].
a nd returns thi s res ul t:
city population
Freebase
Queryi ng Freeba s e for a l l pl a nets of the s ol a r s ys tem:
@{options[outorder(?planetName)]}
57
OntoBroker 6.3 Da ta Integra ti on
?- _restWebserviceAccess(<http://api.freebase.com/api/service/mqlread>, [->],
["query"->"""{"query": [{"id": null, "name": null, "type": "/astronomy/
planet"}]}"""], ?jr) and ?jr[_memberAt("result")->?results[_member->?result]] and ?
result[_memberAt("name")->?planetName].
Res ul t:
planetName
"Ea rth"
"Venus "
"Ma rs "
"Mercury"
"Jupi ter"
"Neptune"
"Sa turn"
Facebook
Sea rch on Fa cebook for publ i c pos ts for "fukus hi ma ":
@{options[outorder(?user,?message,?link)]}
?- _restWebserviceAccess(<http://graph.facebook.com/search>, [->], ["q"->"fukushima",
"type"->"post"], ?jr) and ?jr[_memberAt("data")->?data[_member->?post]] and ?post
[_memberByPath(_path("from", "name"))->?user, _memberAt("message")->?message,
_memberAt("link")->?linkStr] and _iri[_toType(?linkStr)->?link].
Res ul t:
58
OntoBroker 6.3 Da ta Integra ti on
"Ma tthä us Urch" "jedes mona t a m 12ten dements prechnd <http://www.fa cebook.com/event.php?
outfi tten, ni cht verges s en...." ei d=202283566473179>
"Ra y Mcphoney" """hey fri ends my l a tes t rmx i s out thi s <http://s oundcl oud.com/ce-records /
thurs da y on bea tport! here a l i l previ ew: mi guel s tyl e-l i mi ted-mel ody-ra y>
http://s oundcl oud.com/ce-records /
mi guel s tyl e-l i mi ted-mel ody-ra y"""
"Ni col e Ludwi g" "Beei ndruckende Rechnung!" <http://www.gri s t.org/l i s t/2011-04-18-
wha t-i f-the-152-bi l l i on-to-cl ea n-up-
fukus hi ma -were-s pent-on-geot>
"Neues Deuts chl a nd "Weni g Hoffnung rund um Fukus hi ma / Ei n <http://www.neues -deuts chl a nd.de/
Onl i ne" düs teres Szena ri o bes chrei bt Thoma s a rti kel /195821.weni g-hoffnung-rund-um-
Breuer: Innerha l b der Eva kui erungs zone fukus hi ma .html >
um den
ha va ri erten Atomrea ktor und i n den
a ngrenzenden Gebi eten l i egen verl a s s ene
Spi el pl ä tze und di e Ba uern können i hre
Fel der ni cht bes tel l en. Er tri fft übera l l ra t-
und hi l fl os e Mens chen. "
"Eri c Rya n Wei s z" "kennt i hr s chon da s Fukus hi ma -Ei ?" <http://www.youtube.com/wa tch?
v=oEpj6m_hooI&fea ture=pl a yer_embedd
ed#a t=36>
Twitter
Sea rch on Twi tter for l a tes t Engl i s h tweets rel a ted to "fukus hi ma ":
@{options[outorder(?user,?text,?date)]}
?- _restWebserviceAccess(<http://search.twitter.com/search.json>, [->], ["q"-
>"fukushima", "lang"->"en"], ?jr) and ?jr[_memberAt("results")->?results[_member->?
tweet]] and ?tweet[_memberAt("from_user")->?user, _memberAt("text")->?text, _memberAt
("created_at")->?date].
59
OntoBroker 6.3 Da ta Integra ti on
"La vona e818" "Tepco Pl a ns to End Fukus hi ma Nucl ea r Cri s i s by October http://t.co/ "Tue, 19 Apr 2011
Zs VkceE" 15:28:44 +0000"
"ki ng_pa ta " " ? Robots Enter Fukus hi ma "Tue, 19 Apr 2011
Rea ctors , Detect Hi gh Ra di a ti on http://t.co/Fys nFi r vi a 15:28:38 +0000"
@Automa tonBl og"
"ni chi bei " "Hea rts to Is hi noma ki : Fol l ow one woma n’s journey to #Fukus hi ma "Tue, 19 Apr 2011
a nd #Senda i . Through 4/22. http://on.fb.me/e0PT9O" 15:28:19 +0000"
"a ki _ka y1987" " DVD / [DVD] http://a mzn.to/ "Tue, 19 Apr 2011
fQAmEf DVD 15:28:12 +0000"
#DVD #s ougofol l ow #s ogofol l ow #fukus hi ma "
"Ma s a ka zu_Sa "RT @thoton: URGENT: #Ja pa n ma y ra i s e l ega l ra di a ti on l i mi t for "Tue, 19 Apr 2011
ka ta " #Fukus hi ma workers to 1Sv from 250mSv to ha s ten end of cri s i s . (jp) 15:27:56 +0000"
http://a mba .to/dNIjEI"
"htomfi el ds " "#Vi deo of Ida ho Na ti ona l La bora tory Di rector di s cus s i ng l es s ons "Tue, 19 Apr 2011
l ea rned from Three Mi l e Is l a nd a nd #Fukus hi ma http://youtu.be/ 15:27:36 +0000"
vTKdVM53ULU"
"ki ri s ha thegre "RT @s i l vers ta r22b: Fukus hi ma Res i dents Seek Ans wers Ami d Mi xed "Tue, 19 Apr 2011
a t" Si gna l s From Medi a , TEPCO a nd Government. Report from the 15:27:33 +0000"
Ra di a ti on Excl us i o http://ti ny.l y/n27p"
"chri s orr1" "RT @fuyuno_s a kura : In eva cua ti on a rea wi thi n 20 km ra di us of FNPP1, "Tue, 19 Apr 2011
a bout 3,000 ca ttl e, 30,000 pi gs a nd 600,000 chi ckens were l eft behi nd, 15:27:22 +0000"
Fukus hi ma Pref s a i d."
"Ta kMa ts una g "It s a ys mos t i mporta nt to expl a i n to the i nterna ti ona l communi ty the "Tue, 19 Apr 2011
a" current s ta te of the Fukus hi ma Da i i chi "wi th ma xi mum tra ns pa rency"" 15:27:09 +0000"
To get the wea ther for a l l l oca ti ons ma tchi ng "Ka rl s ruhe":
@{options[outorder(?name,?country,?woeid,?condition,?temperature)]}
?- _restWebserviceAccess(<http://query.yahooapis.com/v1/public/yql>, [->], ["q"-
>"select * from geo.places where text=\"Karlsruhe\"", "format"->"json"], ?jr0) AND
?jr0[_memberByPath(_path("query", "results", "place"))->?places[_member->?place
[_memberAt("name")->?name, _memberByPath(_path("admin1", "code"))->?country,
_memberAt("woeid")->?woeid]]] AND
_restWebserviceAccess(<http://weather.yahooapis.com/forecastjson>, [->], ["w"->?
woeid, "u"->"c"], ?jr1) AND
60
OntoBroker 6.3 Da ta Integra ti on
61
OntoBroker 6.3 Da ta Integra ti on
Known Limitations
- Cycl es i n cl a s s hi era rchy mi ght hi de pa rts of the s chema i n OntoStudi o’s ontol ogy na vi ga tor
- If s a mpl i ng i s us ed, the res ul ti ng s chema mi ght be i ncompl ete
- Da ta types us ed i n LOD s ource ha ve to be ma pped for s chema defi ni ti ons to the res tri cted s et us ed by
ObjectLogi c; thi s res tri cti on however i s onl y rel eva nt for the s chema defi ni ti ons
- The s ys tem ca nnot extra ct a s chema from endpoi nts tha t us e a l a rge i mpl i ci tl y decl a red cl a s s s chema a nd
res tri cti ons on query eva l ua ti on ti me or number of returned res ul ts
- Extra cti on of generi c properti es mi ght a dd a l a rge a mount of properti es to the s chema ; the res ul ti ng da ta
s ource ontol ogy mi ght requi re ma nua l cl ea nup
62
OntoBroker 6.3 Supported Import Forma ts
RDF(S)
RDF (Res ource Des cri pti on Fra mework) i s a fra mework for repres enti ng meta da ta . It i s a W3C
recommenda ti on a nd provi des ma ny repres enta ti ons (s ee bel ow). RDFS (RDF s chema ) bui l d upon RDF to
provi de a s i mpl e ontol ogy-l i ke voca bul a ry for denoti ng cl a s s es , properti es , i ns ta nces a nd the rel a ti ons tha t
hol d between them. As we us e the Ses a me RDF pa rs ers (http://www.openrdf.org/) we s upport di fferent RDF
s eri a l i za ti ons :
RDF/XML
N3 (Nota ti on 3)
NT (N-Tri pl es )
Turtl e
We s upport a l l of thes e forma ts for the i mport a nd export of ontol ogi es . For further deta i l s , s ee the
OntoBroker RDF ma nua l .
OWL
The Web Ontol ogy La ngua ge (OWL) i s a l s o recommended by the W3C a nd i s a ful l fl edged ontol ogy l a ngua ge
deri ved from ontol ogy l a ngua ges from the fi el d of Des cri pti on Logi cs . For further deta i l s , s ee the OntoBroker
Profes s i ona l ma nua l .
63
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
7.1 ObjectLogic
ObjectLogi c i s the pri ma ry query l a ngua ge for OntoBroker. It a l l ows a l l ki nds of compl ex queri es . The
fol l owi ng query a s ks for a l l i ns ta nces of the concept "Pers on":
?- ?X:Person.
It i s a l s o pos s i bl e to s ta rt more compl ex queri es whi ch conta i n di s juncti ons , nega ti ons a nd bui l t-i ns :
?- (?X:Person OR ?X:Human) AND NOT ?X[livesIn->Karlsruhe] AND ?X[hasAge->?AGE] AND ?
AGE < 40.
For more deta i l s on ObjectLogi c, pl ea s e cons ul t the ObjectLogi c reference gui de i n the OntoBroker i ns ta l l a ti on
fol der.
Purpose
A ObjectLogi c query i s onl y va l i d i f a l l of i ts va ri a bl es a re i ncl uded. If a ny va ri a bl e ca nnot be bound, the
bi ndi ngs of the other va ri a bl es do not form a res ul t.
Exa mpl e
Fa cts :
Jerry:Person.
Tom:Person.
Jerry[hasName->"Jerry Mouse"].
Query:
?- ?X:Person AND ?X[hasName->?Y].
Res ul t:
X Y
Jerry "Jerry Mouse"
For s ome a ppl i ca ti ons thi s i s not the beha vi our the us er woul d expect. From da ta ba s e s ys tems they a re us ed
to s ee:
X Y
Jerry "Jerry Mouse"
Tom null
To ena bl e OntoBroker to fi l l out the mi s s i ng res ul ts wi th s uch a pl a cehol der the query opti on "fi l l nul l " ca n be
us ed. Thi s fea ture fi l l s up the mi s s i ng va ri a bl e bi ndi ngs wi th a cons ta nt "nul l ".
Usage
Query opti ons i n ObjectLogi c a re wri tten a s a n a nnota ti on i n front of the query
Exa mpl e
Query:
64
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
Restrictions
The query mus t a l l ow the i nferenci ng a l gori thm to fi rs t of a l l ground a l l i ns ta nces a nd rel a ti ons before
ca l l i ng the a ggrega ti on.
Exa mpl e(s ):
@{q1, options[fillnull]} ?- ?X[hasName->?Y].
Thi s wi l l res ul t i n a n error s uch a s the fol l owi ng:
[ERROR]: error on server encountered: com.ontoprise.exception.
LiteralOrderingException: Could not order literals so that
the program is evaluable. This could have the following
reasons: a) a input signature for at least one Built-in could
not be satisfied or b) the program contains unsafe rules
which could not be ordered so that they are top-down evaluable.
Rea s on: The va ri a bl e ?X ca nnot be bound wi th va l ues , s o there i s no orderi ng a va i l a bl e tha t the a ggrega ti on
ca n be ca l l ed (ha s Na me i s a hi dden a ggrega ti on when us i ng fi l l nul l ).
Us i ng i ns tea d:
@{q1, options[fillnull]} ?- ?X:Person AND ?X[hasName->?Y].
Wi l l del i ver the res ul ts , a s X ca n be bound wi th the a va i l a bl e "i ns ta nce of" i nforma ti on. Do not us e a ny bui l t-
i ns for a ttri bute/rel a ti on va l ues :
Exa mpl e:
@{options[fillnull]}?- ?X:C[a->?Y] and _unify(?Y,b).
Bui l t-i ns ca n´t cope wi th the nul l -va l ue. Onl y the _fi l ter(?Y,b) Bui l t-i n wi l l work.
Fi l l nul l i gnores the a s s i gned va l ues of a va ri a bl e:
@{options[fillnull]}?- p(?Y) and ?X:C[a->?Y] .
The a s s i gned va l ue of ?Y i s i gnored.
Wi th
@{q1, options[outorder(?Y,?X)]} ?- ?X::?Y.
the output wi l l be
Person,Man
Person,Woman
The "outorder" opti on ca n a l s o be us ed for s ki ppi ng s ome va ri a bl e bi ndi ngs i n the res ul t: Wi th
@{q1, options[outorder(?X)]} ?- ?X::?Y.
the output wi l l be
Man
Woman
65
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
66
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
Note:
Thi s debuggi ng tool i s not offi ci a l l y s upported. It ha s a coupl e of l i mi ta ti ons whi ch need to be cons i dered
ca reful l y before us i ng the tool :
If you us e "vi s ua l debug" a GUI opens a t the s erver s i de. Thi s mea ns tha t i f you do not ha ve a cces s to the
s erver then you ba s i ca l l y ha ve to res ta rt OntoBroker before conti nui ng.
The debugger i s deepl y i ntegra ted i n the OntoBroker i nference kernel . It i s pos s i bl e tha t the debugger
wi l l cra s h the OntoBroker s erver whi l e or a fter debuggi ng.
To keep a l ong s tory s hort: Never use this tool on a production server!!
In order to debug the eva l ua ti on proces s , s i mpl y a dd "vi s ua l debug" to the ObjectLogi c query:
@{q1, options[visualdebug]} ?- ?X:?Y.
The vi s ua l debugger i s a n a dva nced debuggi ng tool whi ch s hows
The rul e gra ph
The s el ected rul es
The output of the di fferent progra m re wri ters
A gra phi ca l di s pl a y of the compi l ed opera tornet
A s tep-by-s tep debugger whi ch s hows the da ta fl ow i n the opera tornet
We currentl y do not ha ve a deta i l ed documenta ti on on thi s debugger a s thi s tool i s us ed pri ma ry by the
i nterna l OntoBroker res ea rch a nd devel opment tea m.
Note 1:
If a cces s control i s ena bl ed (i .e. the confi gura ti on pa ra meter Securi ty.Acces s Control i s s et to on), you need
the s peci a l permi s s i on "ob:rea s oner:debug" to us e thi s query opti on.
Note 2:
The vi s ua l debugger opti on i s not a va i l a bl e i f you a re us i ng the col l a bora ti on s erver. It wi l l be s i l entl y
i gnored.
Note:
The beha vi our of the query opti on 'i nferOff' ha s been cha nged when ontol ogy i mports a re i nvol ved. E.g.
@{options[inferOff]} ?- ?X:?Y.<br>
wi l l now return a s s erted fa cts a l s o from i mported modul es . If you do not wa nt to recei ve fa cts from
i mported modul es you ca n combi ne 'i nferOff' wi th 'i gnoreImports ':
@{options[inferOff,ignoreImports]} ?- ?X:?Y.
Here i s a s ma l l exa mpl e. The fol l owi ng ObjectLogi c progra m ca l cul a tes the tra ns i ti ve cl os ure of a gra ph:
67
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
edge(a,b).
edge(b,c).
edge(c,d).
edge(d,e).
edge(e,f).
When you execute the query wi th the "profi l e" opti on:
@{q1, options[profile]} ?- closure(?X,?Y,?Z).
then you get s omethi ng l i ke:
---------------------------------------------------
Preparation(#selected: 3, #final: 4)
---------------------------------------------------
11 ms PARSER [OntoBrokerReasoner] Parse and compile query
9 ms PREPARATION [OntoBrokerReasoner] Compile operatornet
6 ms PREPARATION [Evaluator] BottomUp preparation
5 ms REWRITER [SchemaOptimizer]
4 ms PREPARATION [OntoBrokerReasoner] Selection of required rules
1 ms REWRITER [PropagateConstantsRewriter]
... (plus 29 event(s) which took 4 ms)
Preparation time: 42 ms (wall time).
---------------------------------
Most expensive operations
---------------------------------
... (plus 11 operation(s) which took 0 ms)
Operation times: 3 ms (wall time).
---------------------------------
Operator statistics
---------------------------------
bu3joinIDB 5 ms 5 calls [bu3joinIDB [segment { [closure(?X,?Z,?U,
_defaultModule), "assign"(?_X1,f(?Y,?U))}]]
bu3joinEDB 0 ms 1 call [bu3joinEDB [edge(?X,?Y,_defaultModule), "assign"(?_X0,f
(?Y,f(?X,nil)))]]
bu3joinEDB 0 ms 1 call [bu3joinEDB [edge(?Z,?Y,_defaultModule)]]
bu3move 0 ms 1 call [bu3move [segment { [closure(?X,?Y,?Z,_defaultModule)}]]
bu3move 0 ms 1 call [bu3move [segment { ["$QUERY$obl:default:q1"(?X,?Y,?
Z)}]]
Operator times: 6 ms (wall time).
---------------------------------------------------
Rule statistics
---------------------------------------------------
5 ms r2 closure(?X,?Y,?_X1,_defaultModule) :- edge(?Z,?Y,_defaultModule) AND
closure(?X,?Z,?U,_defaultModule) AND "assign"(?_X1,f(?Y,?U)).
0 ms r1 closure(?X,?Y,?_X0,_defaultModule) :- edge(?X,?Y,_defaultModule) AND
"assign"(?_X0,f(?Y,f(?X,nil))).
0 ms q1 "$QUERY$obl:default:q1"(?X,?Y,?Z) :- closure(?X,?Y,?Z,_defaultModule).
0 ms q1 ?- "$QUERY$obl:default:q1"(?X,?Y,?Z).
Rule times: 6 ms (wall time).
---------------------------------------------------
Operatornet execution times
---------------------------------------------------
Wall time: 6 ms.
CPU time: N/A
The res ul ts a bove a re for "Stora ge=RAM.TS" a nd the bottom-up eva l ua tor "BottomUp3". Note tha t the output
for other s tora ge s etti ngs a nd other eva l ua ti on methods ma y be di fferent. The a dmi ni s tra ti on cons ol e wi l l
s how the res ul t of "profi l e" i n a s epa ra te wi ndow:
68
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
The mos t expens i ve opera ti on i s to pa rs e a nd to compi l e the query (11 ms ). The tota l prepa ra ti on ti me i s 42
ms , whi ch mea ns tha t there i s no s peci a l performa nce i s s ue i n the prepa ra ti on pha s e. The next s ecti on
s hows the mos t expens i ve l ow-l evel opera ti ons :
---------------------------------
Most expensive operations
---------------------------------
... (plus 11 operation(s) which took 0 ms)
Operation times: 3 ms (wall time).
Wel l , a t l ea s t i t woul d s how s omethi ng i f there were s ome expens i ve l ow-l evel opera ti ons (e.g. da ta ba s e
a cces s es or very l a rge joi ns ). But our exa mpl e ontol ogy i s too s ma l l a nd s o not much ti me wa s s pent on l ow-
l evel opera ti ons .
The next s ecti on s hows the mos t expens i ve opera tors .
---------------------------------
Operator statistics
---------------------------------
bu3joinIDB 5 ms 5 calls [bu3joinIDB [segment { [closure(?X,?Z,?U,
_defaultModule), "assign"(?_X1,f(?Y,?U))}]]
bu3joinEDB 0 ms 1 call [bu3joinEDB [edge(?X,?Y,_defaultModule), "assign"(?_X0,f
(?Y,f(?X,nil)))]]
bu3joinEDB 0 ms 1 call [bu3joinEDB [edge(?Z,?Y,_defaultModule)]]
69
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
Connectors
Thi s mea ns when you ha ve a n expens i ve connector to a n externa l da ta ba s e i t wi l l s how up i n thi s l i s t. The
next s ecti on i s proba bl y the one on tha t you s houl d l ook a t fi rs t. It s hows the mos t expens i ve rul es of the
eva l ua ti on:
---------------------------------------------------
Rule statistics
---------------------------------------------------
5 ms r2 closure(?X,?Y,?_X1,_defaultModule) :- edge(?Z,?Y,_defaultModule) AND
closure(?X,?Z,?U,_defaultModule) AND "assign"(?_X1,f(?Y,?U)).
0 ms r1 closure(?X,?Y,?_X0,_defaultModule) :- edge(?X,?Y,_defaultModule) AND
"assign"(?_X0,f(?Y,f(?X,nil))).
0 ms q1 "$QUERY$obl:default:q1"(?X,?Y,?Z) :- closure(?X,?Y,?Z,_defaultModule).
0 ms q1 ?- "$QUERY$obl:default:q1"(?X,?Y,?Z).
Rule times: 6 ms (wall time).
In thi s exa mpl e the rul e "r2" i s the mos t expens i ve rul e beca us e i t wi l l be executed mul ti pl e ti mes (i t i s a
recurs i ve rul e).
Exa mpl e
Ontol ogy m1:
:- module = m1.
A[name=>string] .
Second Ontol ogy:
:- module = _defaultModule.
:- import m1.
B::A.
The query
?- B[?P *=> ?R]@_defaultModule.
returns one res ul t (P=na me, R=s tri ng).
But the query
@{q1, options[ignoreImports]} ?- B[?P *=> ?R].
returns no res ul t.
70
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
Let’s ha ve a l ook a t a s i mpl e exa mpl e.The fol l owi ng query reques ts the empl oyee i d a nd the l a s t na me of
empl oyees i n the “Empl oyees ” ta bl e of the da ta ba s e "da ta :1433_Northwi nd_tes t"
?- _dbaccessuser("dbo"."Employees","F"("EmployeeID",?VAR1,"LastName",?
VAR2),"data:1433_Northwind_test").
We get a ns wers l i ke
?VAR1= 1, ?VAR2 = "Davolio ",
?VAR1= 9, ?VAR2 = "Dodsworth",
?VAR1= 8, ?VAR2 = "Callahan"
71
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
7.2 SPARQL
SPARQL i s a W3C s ta nda rd. It i s a query l a ngua ge for RDF (SPARQL: SPARQL Protocol And RDF Query La ngua ge).
Pl ea s e note tha t OntoBroker onl y i mpl ements a s ubs et of SPARQL (a nd SPARQL onl y s upports a s ubs et of the
ObjectLogi c query fea tures ). The fol l owi ng ta bl e s hows how we i nterpret SPARQL queri es i n OntoBroker for
ObjectLogi c ontol ogi es :
Some exa mpl es a re gi ven bel ow. The fi rs t exa mpl e i s a s i mpl e query wi th two tri pl es i n the WHERE pa rt of the
SPARQL query.
SELECT *
WHERE {
?CAR a <http://example.com/#car> ;
<http://example.com/#price> ?PRICE
}
72
OntoBroker 6.3 Query La ngua ges for ObjectLogi c
Thi s exa mpl e s hows a query for s ubcl a s s rel a ti ons hi ps . When we ha ve the ObjectLogi c ontol ogy:
Developer::Employee.
ProjectManager::Employee.
Then the fol l owi ng query
SELECT ?X
WHERE {
?X rdfs:subClassOf ?Y
}
wi l l return:
X
--------------
Developer
ProjectManager
73
OntoBroker 6.3 Run Queri es by Query Id
If you provi de query opti ons , they overwri te the ori gi na l query opti ons , i .e. i t i s pos s i bl e to query
@{options[profile]} ?- _query_(q1)@m2.
Expres s i ons l i ke
?- _query_(q2)@m2 , ?X < 5.
a re a l s o pos s i bl e.
74
OntoBroker 6.3 RIF
9 RIF
Definition:
„The RIF Fra mework for Logi c Di a l ects (RIF-FLD) i s a forma l i s m for s peci fyi ng a l l l ogi c di a l ects of RIF,
i ncl udi ng the RIF Ba s i c Logi c Di a l ect [RIF-BLD] a nd [RIF-Core] (a l bei t not [RIF-PRD], a s the l a tter i s not a
l ogi c-ba s ed RIF di a l ect). RIF-FLD i s a forma l i s m i n whi ch both s ynta x a nd s ema nti cs a re des cri bed through a
number of mecha ni s ms tha t a re commonl y us ed for va ri ous l ogi c l a ngua ges , but a re ra rel y brought a l l
together. The a ma l ga ma ti on of s evera l di fferent mecha ni s ms i s requi red beca us e the fra mework mus t be
broa d enough to a ccommoda te s evera l di fferent types of l ogi c l a ngua ges a nd beca us e va ri ous a dva nced
mecha ni s ms a re needed to fa ci l i ta te tra ns l a ti on i nto a common fra mework. RIF-FLD gi ves preci s e
defi ni ti ons to thes e mecha ni s ms , but a l l ows wel l -defi ned a s pects to va ry. The des i gn of RIF envi s i ons tha t
future s ta nda rd l ogi c di a l ects wi l l be ba s ed on RIF-FLD. Therefore, for a ny RIF di a l ect to become a s ta nda rd,
i ts devel opment s houl d s ta rt a s a s peci a l i za ti on of FLD a nd extens i ons to (or, devi a ti ons from) FLD s houl d
be jus ti fi ed."
Source: http://www.w3.org/TR/ri f-fl d/
9.1 Overview
OntoBroker s upports RIF/XML a s i mport a nd export forma t for ObjectLogi c. The provi ded forma t ha ndl er pa rs es
a gi ven RIF/XML-ba s ed ontol ogy a nd i mports i ts content i nto a n ObjectLogi c ontol ogy a nd, vi ce vers a , a n
ObjectLogi c ontol ogy ca n be s a ved a s RIF/XML. Pl ea s e note tha t not a l l RIF cons tructs i ntroduced by FLD ca n be
ma pped to ObjectLogi c.
ObjectLogic RIF/XML
i ns ta nce:cl a s s <Member>
<instance>T(instance)</instance>
<class>T(class)</class>
</Member>
object[] <Frame>
<object>T(object)</object>
</Frame>
object[property] <Frame>
<object>T(object)</object>
<slot ordered="yes">
75
OntoBroker 6.3 RIF
T(property)
<Const type="&rif;iri">&obld;boolean</Const>
</slot>
</Frame>
76
OntoBroker 6.3 RIF
cl a s s [property <obld:PropertyCharacteristic>
{cha ra cteri s ti c}*=>()]
<obld:object>T(class)</obld:object>
<obld:property>T(property)</obld:property>
<obld:characteristic><Const type="&rif;iri">obl:reserved:
characteristic</Const></obld:characteristic>
</obld:PropertyCharacteristic>
F AND G <And>
<formula>T(F)</formula>
<formula>T(G)</formula>
<And>
F OR G <Or>
<formula>T(F)</formula>
<formula>T(G)</formula>
<Or>
NOT F <Naf>
<formula>T(F)</formula>
<Naf>
F :- G <Implies>
<if>T(G)</if>
<then>T(F)</then>
77
OntoBroker 6.3 RIF
</Implies>
F <-- G <Implies>
<if>T(G)</if>
<then>T(F)</then>
</Implies>
F --> G <Implies>
<if>T(F)</if>
<then>T(G)</then>
</Implies>
F <--> G <obld:Equivalent>
<obld:formula1>T(F)</obld:formula1>
<obld:formula2>T(G)</obld:formula2>
</obld:Equivalent>
?- F <Implies>
<if>T(F)</if>
<then>
<Atom>
<op><Const type="&rif;iri">&obld;query/arity</
Const></op>
<args ordered="yes">
T(id)
T(v1)
...
T(vN)
</args>
</Atom>
</then>
</Implies>
where id is the id of "?- F" (or some placeholder
constant if the formula has no id), v1,..., vN are
the free variables in F and arity is N + 1. Query options
are serialized as annotations (not presented here).
!- F <Implies>
<if>T(F)</if>
<then>
<Atom>
<op><Const type="&rif;iri">&obld;constraint/arity</
Const></op>
<args ordered="yes">
T(id)
T(v1)
78
OntoBroker 6.3 RIF
...
T(vN)
</args>
</Atom>
</then>
</Implies>
where id is the id of "!- F"
(or some placeholder constant if the
formula has no id), v1,..., vN are the free variables in F
and arity is N + 1.
?X <Var>X</Var>
79
OntoBroker 6.3 RIF
</args>
</Expr>
where {vi_j | j=1,...,Mi}, i = 1,...,N, is the set of values
for key ti
9.2.3 Forall-Closing
If a top l evel ObjectLogi c formul a F ha s free va ri a bl es , the tra ns forma ti on fora l l -cl os es the tra ns formed
formul a . If F ha s a n i d or a nnota ti ons , they a ppl y to the fora l l -cl os ed formul a . On the other ha nd, the re-
tra ns forma ti on removes unneces s a ry fora l l -qua nti fi ers on the top l evel of formul a s a nd ma ps the i d a nd
a nnota ti ons to the res ul ti ng formul a .
9.2.4 Modules
ObjectLogi c s epa ra tes the knowl edge ba s e of ontol ogi es expl i ci tl y us i ng modul es . If a n ObjectLogi c formul a
conta i ns a modul e defi ni ti on, i t wi l l be tra ns formed to a s peci a l a nnota ti on.
ObjectLogic RIF/XML
80
OntoBroker 6.3 RIF
Thes e RIF terms mus t not be us ed ba ckwa rds i n formul a pos i ti ons :
Cons ta nt.
81
OntoBroker 6.3 RIF
Va ri a bl e.
9.4 API
9.4.1 Import
Jus t open a gi ven RIF/XML ontol ogy a s i f i t woul d be a na ti ve ObjectLogi c ontol ogy:
OntologyManager oblOntologyManager = ...;
oblOntologyManager.openOntology(ontologyURI, parameters);
The ontol ogy URI i n a RIF ontol ogy i s i denti fi ed by the a nnota ti on ID of the document formul a . If i t ha s none,
the phys i ca l URI i s us ed a s the ontol ogy URI. As us ua l ; i f neces s a ry you wi l l ha ve to regi s ter a n ontol ogy to a
phys i ca l URI ma ppi ng i n the ontol ogy res ol ver of the ontol ogy ma na ger.
Al terna ti vel y us e
oblOntologyManager.importOntology(new File(physicalURI), ...);
to i mport a RIF/XML ontol ogy wi thout the need to regi s ter a n ontol ogy to a phys i ca l URI ma ppi ng.
9.4.2 Export
Sa ve a n ObjectLogi c ontol ogy a s RIF/XML us i ng the corres pondi ng fi l e forma t ha ndl er i denti fi ed by
OntoBrokerOntol ogyFi l eForma t.RIF_OBLD_XML_FOR_FLOGIC2, e.g.:
oblOntology.saveOntology(OntoBrokerOntologyFileFormat.RIF_OBLD_XML, file);
82
OntoBroker 6.3 Project Fi l es
10 Project Files
OntoBroker s upports project fi l es for ea s i er ha ndl i ng of mul ti pl e ontol ogi es . A project fi l e s peci fi es :
Wha t ontol ogy fi l es a re l oa ded
In whi ch modul e ontol ogy fi l es a re l oa ded
The project fi l es ha ve a very s i mpl e s ynta x wi th the two ta s ks "l oa d" a nd "res ol ve" (for more i nforma ti on s ee "
Loa d Sa ve 199 ") whi ch we expl a i n bel ow us i ng s ome exa mpl es . If you wa nt to us e project fi l es , s ta rt
OntoBroker wi th -project <projectfile> .
Note:
Al l cha ra cters i n a l i ne a fter // a re comments .
83
OntoBroker 6.3 Project Fi l es
Fi l e 1:
:- module=m1.
:- import=m2.
B::A.
Fi l e 2:
:- module=m2.
C::A.
If we wri te
load "file1.obl" // module m1
load "file2.obl" // module m2
i n the project fi l e then we ha ve two ontol ogy objects a nd the extens i ona l da ta ba s e conta i ns the fa cts
B::A@m1.
C::A@m2.
In thi s ca s e we ha ve
B::A@m1.
C::A@m1.
i n the extens i ona l da ta ba s e (whi ch wi l l provi de better performa nce).
84
OntoBroker 6.3 Ma teri a l i za ti on
11 Materialization
Wha t i s "ma teri a l i za ti on"? Ma teri a l i za ti on a l wa ys mea ns tha t OntoBroker eva l ua tes rul es i n a dva nce (on
s ta rtup) a nd s tores the res ul ts i n the extens i ona l da ta ba s e (EDB). Thi s ha s the fol l owi ng effects :
Queri es ca n be executed very fa s t (a s OntoBroker ha s fewer rul es to eva l ua te).
OntoBroker needs more memory (a s a l l fa cts defi ned i mpl i ci tl y by rul es a re s tored i n the da ta ba s e).
The s ta rtup ti me i ncrea s es (s ometi mes s i gni fi ca ntl y beca us e a l l of the rea s oni ng i s done i n the s ta rtup
pha s e).
So to keep i t s hort: Ma teri a l i za ti on i s a very good wa y to opti mi ze performa nce a nd to provi de gua ra nteed
a ns weri ng ti mes . Another i mporta nt us e ca s e for ma teri a l i za ti on i s to ma teri a l i ze da ta ba s e ma ppi ng rul es .
Thi s wa y the us ers of the ontol ogy ca n execute offl i ne queri es (wi thout a cces s to the ma pped da ta ba s e).
Note:
Ma teri a l i za ti on i s onl y s upported for the ontol ogy l a nguga ges ObjectLogi c a nd RDF. Currentl y OWL
ontol ogi es ca nnot be ma teri a l i zed.
Tip:
If you wa nt to s tore the ma teri a l i zed fa cts i n a fi l e, jus t s ta rt OntoBroker wi th the -m opti on a nd execute the
"exportAl l Modul es " comma nd. OntoBroker wi l l dump a l l fa cts a nd rul es of a l l ontol ogi es of the knowl edge
ba s e to mul ti pl e fi l es .
Tip:
You ca n us e the new "-runs cri pt" comma ndl i ne opti on when s ta rti ng the s erver to ma teri a l i ze a s et of rul es
a nd s tore the res ul ti ng ontol ogi es i n a fi l e. Thi s a l l ows you to ma teri a l i ze rul es i n a ba tch job.
85
OntoBroker 6.3 Ma teri a l i za ti on
wi l l not be s tored i n the ta bl e "i ns ta nceOf", but i ns tea d i t wi l l be s tored i n the ta bl e "MAT_i ns ta nceOf".
Thi s wa y OntoBroker ca n di fferenti a te between ba s e fa cts a nd ma teri a l i zed fa cts . Hence i t i s pos s i bl e to
revert a nd upda te the ma teri a l i za ti on. If you wa nt the ma teri a l i za ti on to be upda ta bl e then you ha ve to
ma teri a l i ze vi a
OntoBroker32.exe -m:update someRulesToBeMaterialized.obl
or vi a
start-ontobroker.sh -m:update someRulesToBeMaterialized.obl
on Uni x-ba s ed s ys tems .
If you don't wa nt to upda te the ma teri a l i za ti on you ma teri a l i ze the rul es thi s wa y:
OntoBroker32.exe -m:noupdate someRulesToBeMaterialized.obl
or
OntoBroker32.exe -m someRulesToBeMaterialized.obl
In thi s ca s e the ma teri a l i zed fa cts wi l l be s tored i n the s a me ta bl es a s the ba s e fa cts . So i t i s no l onger
pos s i bl e to di fferenti a te between the two types of fa cts .
Materialization strategies
OntoBroker s upports di fferent ma teri a l i za ti on s tra tegi es . The "DRed" s tra tegy works i ncrementa l l y, the "RFS"
s tra tegy wi l l upda te the knowl edge ba s e from s cra tch. Whi ch s tra tegy wi l l del i ver better performa nce
depends on your rul es a nd the cha nge ra te.
Note:
Thi s ma teri a l i za ti on s tra tegy wi l l del a y cha nges to the ontol ogy unti l the ma teri a l i za ti on i s tri ggered a ga i n.
Thi s mea ns i f you a dd a fa ct then queri es a nd reques ts for thi s fa ct wi l l onl y return the expected res ul t a fter
the ma teri a l i za ti on wa s executed a ga i n.
The DRed a l gori thm i s a wel l -known ma teri a l l i za ti on a l gori thm (ori gi na l pa per: "Ma i nta i ni ng Vi ews
Incrementa l l y" by Gupta , Mumi ck, Subra ha ma ni a n). We us e a pure decl a ra ti ve vers i on of the a l gori thm.
Ba s i ca l l y we rewri te rul es l i ke
p(?X,?Z) :- q(?X,?Y) AND r(?Y,?Z).
to the ma i ntena nce rul es
p_plus(?X,?Z) :- q_insert(?X,?Y) AND r(?Y,?Z).
p_plus(?X,?Z) :- q(?X,?Y) AND r_insert(?Y,?Z).
Then we execute queri es on the "p_pl us " predi ca tes a nd a dd the res ul ts to the "p" ta bl e of the EDB.
86
OntoBroker 6.3 Ma teri a l i za ti on
Note:
Currentl y bul k cha nge opera ti ons a re not s upported.
Update strategies
Immediately
Thi s upda te s tra tegy wi l l execute the ma teri a l i za ti on a s s oon i mmedi a tel y a fter a fa ct or rul e wa s a dded or
removed.
Triggered
Thi s upda te s tra tegy wi l l execute the ma teri a l i za ti on onl y when the "ma t_executeMa teri a l i za ti on 87 "
comma nd wa s executed. A typi ca l s cena ri o i s to upda te the ma teri a l i za ti on a t s ome ti me where no one
a cces s es the s erver (e.g. once a ni ght).
87
OntoBroker 6.3 Ma teri a l i za ti on
Add Rul e a s Ma teri a l i zed Rul e (For mat_addRule <ruleID>, To ma teri a l i ze the rul e
Upda ta bl e Ma teri a l i za ti on Onl y) <ontologyID> @{r1} ?X[enemyOf->Jerry] :-
?X:Cat AND ?X[hasName-
>Tom].
of ontol ogy "comi cs " you ha ve to
execute the comma nd
mat_addRule r1, comics
If you us e the API you ca n wri te
OntologyManager manager;
manager.execute
("mat_addRule r1 comics");
Remove Rul e a s Ma teri a l i zed Rul e mat_removeRule <ruleID>, Thi s comma nd wi l l remove the rul e
(For Upda ta bl e Ma teri a l i za ti on <ontologyID> wi th the gi ven ID a s a ma teri a l i zed
Onl y) rul e. Note tha t the rul e s ti l l
rema i ns i n the ontol ogy. The
ma teri a l i zed fa cts for thi s rul e wi l l
be removed.
88
OntoBroker 6.3 Ma teri a l i za ti on
89
OntoBroker 6.3 Ma teri a l i za ti on
90
OntoBroker 6.3 Interfa ces to OntoBroker
12 Interfaces to OntoBroker
The OntoBroker s erver ca n be a cces s ed from mul ti pl e progra mmi ng l a ngua ges a nd pl a tforms :
Ja va 92
Mi cros oft .NET 109
Web s ervi ce 109
You ca n execute OntoBroker queri es a nd comma nds vi a the s ta nda rd webs ervi ce i nterfa ce from a l l
progra mmi ng pl a tforms tha t ha ve s ome ki nd of webs ervi ces l i bra ry. The fol l owi ng cha pters gi ve more deta i l s
a nd s ome exa mpl es on how to do thi s . It i s a l s o pos s i bl e to embed OntoBroker i nto your own Ja va
a ppl i ca ti ons . Jus t a dd the OntoBroker l i bra ri es to your a ppl i ca ti on a nd devel op progra ms us i ng the
OntoBroker Ja va API 92 .
Getting Started
The s ocket cl i ent API wa s des i gned s o tha t you onl y need one OntoBroker l i bra ry to a dd to your CLASSPATH.
Jus t ta ke the:
com.ontoprise.ontobroker.socketclient_6.0.0.jar
from the "pl ugi ns " di rectory of your i ns ta l l a ti on a nd a dd i t to your progra m.
Short Tutorial
The ba s i c i dea behi nd the API i s tha t you need a connecti on object for a l l a cti ons (queri es a nd comma nds ).
Connecti on objects ca n be crea ted vi a
OntoBrokerConnection conn = OntoBrokerConnectionManager.getConnection();
The connecti on ma na ger a utoma ti ca l l y opens the connecti on a nd tri es to connect to a n i nference s erver. If
the us er na me a nd pa s s word a re provi ded, the ma na ger wi l l a uthenti ca te wi th the s erver. Note tha t the
va ri ous "getConnecti on()" methods a l l ow a rguments for s peci fyi ng hos t, port, us er na me, pa s s word a nd
s ocket ti meout.
91
OntoBroker 6.3 Interfa ces to OntoBroker
The "Pri nti ngCons umer" i s a s i mpl e i mpl ementa ti on of the ca l l ba ck i nterfa ce:
private class PrintingConsumer implements ClientQueryConsumer {
@Override
public void receivedQueryFinished() {
System.out.println("Done.");
}
@Override
public void receivedQueryStarted(long queryKey, String[] variableNames) {
System.out.println("Query started: " + queryKey);
_resultArity = variableNames.length;
for (int i=0; i<_resultArity; i++) {
if (i != 0) {
System.out.print(", ");
}
System.out.print(variableNames[i]);
}
System.out.println();
}
@Override
public void receivedTraceMessage(String msg) {
System.out.println(msg);
}
@Override
public void receivedTuple(ClientTerm[] tupleBuffer) {
for (int i=0; i<_resultArity; i++) {
if (i != 0) {
System.out.print(", ");
}
System.out.print(tupleBuffer[i]);
}
System.out.println();
}
The "Cl i entTerm" l ooks s i mi l a r to the "Term" i nterfa ce, but beha ves di fferentl y:
It i s not i nterna l i zed. Thi s mea ns tha t two equa l terms ma y not be i denti ca l .
The "toStri ng()" method onl y s upports ObjectLogi c
Bes i des thi s , ha ndl i ng i s s i mi l a r to the KAON2 API. For exa mpl e, you ca n ca l l a "getType()" method whi ch wi l l
return a "Cl i entDa ta type" whi ch a l l ows you to check i f the term i s a IRI cons ta nt, a s tri ng cons ta nt, a l i s t, ...
92
OntoBroker 6.3 Interfa ces to OntoBroker
Accessing OntoBroker
The preferred wa y of a cces s i ng the OntoBroker Ja va API i s vi a the 'Remote API' (for our purpos es equi va l ent to
the 'Col l a bora ti on Server' mode a nd further referred to a s 'remote API'); onl y the remote API i s gua ra nteed to
s upport the compl ete API fea ture s et.
Us i ng the remote API mea ns runni ng OntoBroker i ndependentl y from the a ppl i ca ti on bei ng devel oped,
potenti a l l y on a di fferent computer.
OntoBroker Setup
In order to s ta rt us i ng the remote API, OntoBroker ha s to be confi gured to a l l ow connecti ons vi a the 'Remote
API' or 'Col l a bora ti on Server'. If you pl a n on runni ng OntoBroker on a di fferent computer for devel opment
purpos es , ena bl i ng the Web Cons ol e wi l l l et you control the s erver ea s i l y from your devel opment
works ta ti on. To try out the exa mpl es a nd demo a ppl i ca ti ons pres ented, remember to confi gure OntoBroker to
us e ObjectLogi c. Refer to the OntoBroker documenta ti on for further i nforma ti on on confi gura ti on.
If you run OntoBroker on a di fferent ma chi ne, a djus t the hos tna me or IP a ddres s i n the exa mpl e code. In ca s e
of connecti on probl ems , ma ke s ure tha t OntoBroker i s rea l l y runni ng a nd check the fi rewa l l s etti ngs .
OntologyManager
Ha vi ng touched on connecti ng to a n OntoBroker i ns ta nce, l et us now s ee how thi s ca n be progra mmed. The
centra l poi nt for es ta bl i s hi ng a connecti on to OntoBroker a nd ma na gi ng ontol ogi es i s the s o-ca l l ed Ontol ogy
Ma na ger. Ontol ogyMa na ger i s pa ra meteri zed by a Properti es object, tha t hol ds a ny rel eva nt connecti on
s etti ngs a nd s peci fi es the ontol ogy l a ngua ge of choi ce.
Thi s code s ni ppet bel ow i ns ta nti a tes a n Ontol ogyMa na ger for the ObjectLogi c l a ngua ge. The va ri a bl e url i n
the fourth l i ne mus t hol d the hos tna me or IP of the OntoBroker i ns ta nce, i n our exa mpl es , thi s wi l l be
"l oca l hos t". Al s o note the two commented out l i nes for s etti ng the us erna me a nd pa s s word, unl es s you
cha nge the defa ul t s ecuri ty OntoBroker s etti ngs , thes e wi l l not be needed.
// create a new ontology manager for ObjectLogic
Properties properties = new Properties();
properties.put(IConfig.ONTOLOGY_LANGUAGE, OntologyLanguage.OBJECTLOGIC.toString());
properties.setProperty("CollaborationServer.Url", url); // IP or hostname
of OntoBroker
// properties.setProperty("CollaborationServer.User", "username"); // if applicable
// properties.setProperty("CollaborationServer.Password", "psswd"); // if applicable
OntologyManager manager = KAON2Manager.newOntologyManager(properties)
Note:
Ignori ng s ecuri ty s etti ngs mi ght be a ccepta bl e for devel opment, however, ma ke s ure to s ecure OntoBroker
properl y for producti on us e. For more i nforma ti on, s ee the OntoBroker documenta ti on.
Note:
The exa mpl es menti oned i n the API documenta ti on ca n be downl oa ded a t http://otc.ontopri s e.com ->
Downl oa ds (regi s tra ti on i s free).
93
OntoBroker 6.3 Interfa ces to OntoBroker
Deleting an Ontology
When a n ontol ogy i s no l onger needed, i t ca n be del eted. Del eti ng removes the ontol ogy from the ma na ger
ma ki ng i t una va i l a bl e unti l i t i s re-i mported a ga i n. Thi s does not, however, modi fy the fi l e s ys tem, s houl d the
ontol ogy be ori gi na l l y i mported from a fi l e or not.
// delete an ontology
Ontology ontology = manager.getOntology("http://www.example.org/MyOnto");
manager.deleteOntology(ontology);
12.2.2.1 Retrieval
94
OntoBroker 6.3 Interfa ces to OntoBroker
rea s oni ng, s o tha t, for exa mpl e, a ttri bute va l ues deri ved by rul es a re cons i dered. Thi s ki nd of i nforma ti on
retri eva l i s i denti ca l to a ns weri ng queri es pos ed i n the OntoBroker text query wi ndow.
On the other ha nd, a ns weri ng reques ts onl y i nvol ves expl i ci tl y s ta ted (or a s s erted) fa cts . Ans weri ng reques ts
res embl es s ynta cti c ma tchi ng.
12.2.2.11 Queries
Namespaces
To keep the code rea da bl e, we a voi d us i ng ful l y qua l i fi ed na mes for concepts a nd properti es . Thi s i s ma de
pos s i bl e by a Na mes pa ces object. A Na mes pa ces object ca n be a s s i gned one defa ul t a nd mul ti pl e prefi xed
na mes pa ces a l l owi ng for more conci s e ObjectLogi c code.
Namespaces ns = new Namespaces();
ns.setDefaultNamespace("http://www.ontoprise.de/ontology1#";);
95
OntoBroker 6.3 Interfa ces to OntoBroker
Often, the number of tupl es i n a res ul t s et i s not previ ous l y known a nd, i n thi s ca s e, the a fterLa s t() method
comes i n ha ndy. Thi s method i ndi ca tes i f we ha ve gone through a l l the tupl es i n the res ul t s et. If not,
tupl eBuffer() returns the current n-tupl e a s a n a rra y of Terms (See bel ow for more i nforma ti on a bout query
return types ). The method next() moves a query's i nterna l i tera tor to the next tupl e.
query.open()
Term[] tuple = query.tupleBuffer();
while (!query.afterLast()) {
System.out.println("Temp on " + tuple[0] + " was " + tuple[1]);
query.next();
}
query.close();
12.2.2.12 Requests
As a l rea dy expl a i ned, reques ts ci rcumvent a ny rea s oni ng a nd fetch a xi oms a s expl i ci tl y entered i n the
knowl edge ba s e. The fol l owi ng i l l us tra tes reques ti ng a xi oms wi th a s i mpl e condi ti on.
Setting Conditions
Dependi ng on the type of object bei ng reques ted, di fferent condi ti ons ca n be s et. Axi oms perta i ni ng to
ObjectLogi c concepts , i ns ta nces a nd properti es a re concentra ted i n the cl a s s hi era rchy bel ow FAtom, ea ch of
thes e cl a s s es defi nes s tri ng cons ta nts for the a ppl i ca bl e condi ti ons (s ee the ja va doc). The condi ti ons a re
s el f-expl a na tory a nd fol l ow from wha t i nforma ti on a pa rti cul a r FAtom s ubcl a s s ca rri es .
For exa mpl e, the FCl a s s Member bi nds a n i ns ta nce (ca l l ed 'object') to a concept (ca l l ed 'cl a s s object'). Si nce
we i ntend to reques t the i ns ta nces of a pa rti cul a r concept, we s et a condi ti on on the concept ('cl a s s object'),
tha t s houl d be equa l to the pa rti cul a r concept na me.
request.setCondition(FClassMember.CLASS_OBJECT_REQUEST_CONDITION_KEY,
KAON2Manager.factory().constantIRI("http://www.ontoprise.de/ontology1#City"));
Mul ti pl e va l ues for a condi ti on ca n a l s o be s peci fi ed us i ng the method s etCondi ti onMul ti pl eVa l ues . Any one
of the s peci fi ed va l ues wi l l then qua l i fy a record for i ncl us i on. Cons i der the fol l owi ng va ri a ti on of the
previ ous condi ti on; i n a ddi ti on to i ns ta nces of Ci ty, i ns ta nces of Vi l l a ge woul d a l s o be i ncl uded i n the res ul t.
request.setConditionMultipleValues(FClassMember.CLASS_OBJECT_REQUEST_CONDITION_KEY,
KAON2Manager.factory().constantIRI("http://www.ontoprise.de/ontology1#City"));
KAON2Manager.factory().constantIRI("http://www.ontoprise.de/ontology1#Village"));
96
OntoBroker 6.3 Interfa ces to OntoBroker
Accessing Results
The Reques t cl a s s provi des s evera l methods for a cces s i ng the res ul ts , bei ng i nteres ted i n a l l ma tchi ng
a xi oms from the current ontol ogy, we ca l l the pl a i n get() va ri a nt. Thi s returns the compl ete res ul t s et a t once
a s a typed Set of FCl a s s Member. In l i ne wi th our expecta ti ons , the type of the res ul t el ements corres ponds to
the type reques ted, we ca n therefore di rectl y ma ke us e of the three a cces s or methods .
Set<FPropertyMember> result = request.get();
for (FPropertyMember ax : result) {
The concepts or properti es i n a n ontol ogy often form a hi era rchy. The ontol ogy cl a s s provi des methods for
retri evi ng thes e hi era rchi es tha t ca n then be ea s i l y tra vers ed.
Thi s l i s ti ng s hows output from a s a mpl e progra m for pri nti ng the concept hi era rchy:
Area
City
Country
Federal State
Weather Station
Measurement
Date
CityWithID
Retrieving a Hierarchy
There a re two methods a va i l a bl e for retri evi ng hi era rchi es : getConceptHi era rchy a nd getPropertyHi era rchy. For
both, the object returned i s of the type Hi era rchy.
Hierarchy hierarchy = ontology.getConceptHierarchy(false);
97
OntoBroker 6.3 Interfa ces to OntoBroker
Traversing a Hierarchy
The tra vers a l ca n be s ta rted a t the root nodes proceedi ng the chi l d nodes , or by jumpi ng to a concrete node
corres pondi ng to a pa rti cul a r concept or property; the fol l owi ng code s ni ppet demons tra tes the fi rs t opti on
(s ee the s a mpl e progra m for a s l i ghtl y more s ophi s ti ca ted i mpl ementa ti on):
for (Term t : hier.getRootTerms()) {
Node n = hier.getNodeFor(t);
printNodeHierarchy(n);
}
void printNodeHierarchy(Node n) {
System.out.println(n.getTerm());
for (Node cn : n.getChildNodes())
printNodeHierarchy(cn);
}
12.2.2.2 Modifications
Ontol ogy contents ca n be modi fi ed i n two wa ys ; by a ddi ng a nd removi ng a xi oms . Thes e a cti vi ti es a re cl os el y
rel a ted to Reques ts (pl ea s e remember tha t reques ts retri eve a s s erted fa cts , i .e. expl i ci tl y s ta ted knowl edge
ba s e el ements ). Removi ng a xi oms , for exa mpl e, woul d typi ca l l y be preceded by pl a ci ng a reques t. There i s a n
a l terna ti ve a pproa ch to modi fyi ng ontol ogy contents us i ng s o-ca l l ed bul k opera ti ons a s demons tra ted bel ow.
Note:
The us e of the na mes pa ces object tha t frees us from ha vi ng to wri te out the ful l y qua l i fi ed object na mes .
An equi va l ent a xi om ca n be crea ted di rectl y from ObjectLogi c code a s the next code s ni ppet i l l us tra tes :
Axiom axText = factory.axiom("Heidelberg:City.", namespaces, geographyOnto.getModule
());
Bulk Operations
As menti oned i n the i ntroducti on, i t i s a l s o pos s i bl e to a dd or remove mul ti pl e a xi oms a t once wi thout
ha vi ng to s peci fy ea ch one of them i ndi vi dua l l y. The des cri bed functi ona l i ty i s a va i l a bl e i n the form of the
two methods bul kAddFa cts a nd bul kRemoveFa cts of a n Ontol ogy object. They both work i n a s i mi l a r fa s hi on;
one pa ra meter s peci fi es a pa ttern a ga i ns t whi ch exi s ti ng a xi oms a re to be ma tched. The ma tchi ng works very
much l i ke eva l ua ti ng a reques t, i .e. no rea s oni ng i s performed a nd a va i l a bl e a xi oms a re s i mpl y compa red
wi th the provi ded pres cri pti on; thi s pres cri pti on (or pa ttern) a l s o i ntroduces va ri a bl es tha t a re us ed i n the
98
OntoBroker 6.3 Interfa ces to OntoBroker
s econd pa ra meter to des cri be the cha nges to be ca rri ed out i n a generi c wa y.
The mea ni ng of the s econd pa ra meter i s di fferent for the two bul k opera ti ons . The s econd pa ra meter of the
bul kAdd opera ti on s peci fi es fa cts tha t s houl d be a s s erted true a fter the executi on of the opera ti on. Tha t i s , i f
the fa cts from the s econd pa ra meter do not a l rea dy exi s t for a ma tchi ng va ri a bl e a s s i gnment, they wi l l be
a dded to the knowl edge ba s e. On the other ha nd, the bul kRemove opera ti on a s s erts the fa cts from the
s econd pa ra meter fa l s e, i .e. i f for a va ri a bl e a s s i gnment (from the fi rs t pa ra meter) fa cts of the form s peci fi ed
by the s econd pa ra meter exi s t, they wi l l be removed from the knowl edge ba s e.
To demons tra te thi s functi ona l i ty a s s ume tha t there i s a n ontol ogy conta i ni ng Germa n ci ti es a l ong wi th the
federa l s ta te they bel ong to. Ci ti es a re expres s ed a s i ns ta nces of a concept ca l l ed Ci ty a nd rel a ted to the
res pecti ve s ta tes by a property ca l l ed pa rtOfFedera l Sta te. For the s a ke of the exa mpl e, a s s ume tha t we
i ntroduce a new concept ca l l ed Ba va ri a nCi ty a s a s ubconcept of Ci ty a nd i ntend to ma ke a l l of the exi s ti ng
ci ti es l oca ted i n Ba va ri a i ns ta nces of thi s new concept, ra ther tha n of the generi c ci ty.
The condi ti on or pa ttern for ma tchi ng ci ti es i n Ba va ri a i s compos ed of two a xi oms . The fi rs t a xi om,
formul a Pa rtOfBa yern, s ta tes tha t a va ri a bl e C i s a s s i gned to a n i ns ta nce ca l l ed Ba yern by the mea ns of a
property ca l l ed pa rtOfFedera l Sta te:
Term var = factory.variable("C");
Term partOf = factory.constantIRI(ns, "partOfFederalState");
Term bayern = factory.constantIRI(ns, "Bayern");
FactFormula formulaPartOfBayern = factory.fpropertyMember(var, partOf, bayern);
The s econd a xi om, formul a Is Ci ty, s ta tes tha t the s a me va ri a bl e i s a n i ns ta nce of a concept ca l l ed Ci ty;
Term city = factory.constantIRI(ns, "City");
FactFormula formulaIsCity = factory.fclassMember(var, city);
Thes e two a xi om form the compl ete condi ti on, or pa ttern for ma tchi ng exi s ti ng fa cts :
List<FactFormula> queryList = new ArrayList<FactFormula>();
queryList.add(formulaPartOfBayern);
queryList.add(formulaIsCity);
Now, we need to expres s the cha nges tha t need to be ma de. Let us fi rs t of a l l focus on a s s i gni ng the
ma tchi ng i ns ta nces to the new concept Ba va ri a nCi ty. Upon executi on, the ma tchi ng i ns ta nces s houl d be
a s s i gned to the new concept. Thi s i s done by us i ng the s a me va ri a bl e to des cri be the s ta te a fter executi on.
Term bavCity = factory.constantIRI(ns, "BavarianCity");
FactFormula formulaIsBavCity = factory.fclassMember(var, bavCity);
List<FactFormula> addList = new ArrayList<FactFormula>();
addList.add(formulaIsBavCity);
Ha vi ng prepa red both a rguments , we ca n now perform the bul kAdd opera ti on:
geographyOnto.bulkAddFacts(queryList, addList);
At thi s poi nt the Ba va ri a n ci ti es a re expl i ci tl y a s s i gned to both concepts , City a nd BavarianCity. To remove
thi s pos s i bl e s ource of i ncons i s tenci es , we wi l l us e the bul kRemove opera ti on to remove the Ba va ri a n ci ti es
from the regul a r City concept. Thi s i s ea s i l y done a s we a l rea dy ha ve a pa ttern to ma tch a ga i ns t tha t we ca n
reus e:
List<FactFormula> removeList = new ArrayList<FactFormula>();
removeList.add(formulaIsCity);
geographyOnto.bulkRemoveFacts(queryList, removeList);
The bul k opera ti ons offer a hi gh-performa nce a l terna ti ve, es peci a l l y i n the ca s e of cha nges i nvol vi ng l a rge
numbers of a xi oms .
99
OntoBroker 6.3 Interfa ces to OntoBroker
Implementing a DatamodelListener
In order to moni tor ontol ogy cha nges , the Da ta model Li s tener i nterfa ce mus t be i mpl emented. The i nterfa ce
i s i ntui ti ve conta i ni ng a s i ngl e method ha ndl eEvent, whi ch recei ves one a rgument of the generi c type
Da ta model Event. Concrete events ca n be di fferenti a ted ba s ed on the pa rti cul a r dyna mi c type of thi s a rgument
(s ee the ja va doc for the pos s i bl e s ubtypes ). For exa mpl e, when a xi oms a re a dded or del eted from a n
ontol ogy, events of type Axi oms Upda tedEvent a re ra i s ed.
The fol l owi ng code s ni ppets s how a s i mpl e Da ta model Li s tener i mpl ementa ti on whi ch pri nts the s tri ng
repres enta ti on of a n a dded a xi om.
class AddListener implements DatamodelListener {
Formatting form = new Formatting(OntologyLanguage.OBJECTLOGIC);
Registering a Listener
The l i s tener ca n be regi s tered a t a n Ontol ogyMa na ger by ca l l i ng the a ddDa ta model Li s tener method. Bes i des
a Da ta model Li s tener i ns ta nce, one a ddi ti ona l a rgument of type Da ta model EventFi l ter i s requi red. The fi l ter
control s whi ch events of whi ch type, occurri ng i n whi ch ontol ogi es , a re pa s s ed to a l i s tener. The fol l owi ng
i ns ta nti a tes a fi l ter for the AXIOMS_UPDATED event i n one ontol ogy:
ArrayList<Integer> ontoIds = new ArrayList<Integer>(1);
ontoIds.add(ontology.getOntologyID());
DatamodelEventFilter filter = new DatamodelEventFilter(ontoIds, EnumSet
.of(DatamodelEvent.EventType.AXIOMS_UPDATED), true);
12.2.4 Autocomplete
The a uto-compl ete fea ture ena bl es ea s y us er i ntera cti on wi th the OntoBroker-ba s ed a ppl i ca ti on by provi di ng
a l i s t of pa rti a l textua l ma tches to the us er whi l s t enteri ng a n exi s ti ng term na me.
100
OntoBroker 6.3 Interfa ces to OntoBroker
Autocompl ete s upport covers concepts , i ns ta nces , a ttri butes , a nd rel a ti ons . The compl eti on res ul ts a re
ba s i ca l l y term na mes from a n ontol ogy ma tchi ng a us er-s uppl i ed na me prefi x (the begi nni ng of a l oca l term
na me). Opti ona l condi ti ons a nd s ea rch opti ons ca n be s peci fi ed to further cons tra i n the s ea rch.
The a utocompl ete functi ona l i ty i s a cces s i bl e through the Autocompl eteHel per cl a s s i n the pa cka ge com.
ontopri s e.i ndexer. As Autocompl eteHel per's pa cka ge l oca ti on s ugges ts , i t ma kes us e of the i ndexer
i nfra s tructure, tha t the progra mmer, however, need not be concerned wi th other tha n to ens ure tha t the
i ndexer i s ena bl ed i n the ontol ogy ma na ger.
The fol l owi ng text bri efl y expl a i ns ba s i c us a ge of the Autocompl eteHel per cl a s s (compl ete s ource code for
a n exa mpl e progra m i s a va i l a bl e a t the end).
Indexer
Si nce we a re worki ng wi th ontol ogi es , we fi rs t need to i ns ta nti a te a n Ontol ogyMa na ger object a s us ua l ,
s uppl yi ng the property va l ues rel eva nt for our envi ronment.
Incl ude the i ndexer ena bl i ng opti on:
Properties props = new Properties();
...
props.setProperty("FullTextIndex", "on"); // Enable the indexer
OntologyManager manager = KAON2Manager.newOntologyManager(props);
Note:
Ena bl e the i ndexer i n Ontol ogyMa na ger.
AutocompleteHelper Setup
After s etti ng up a n Ontol ogyMa na ger a nd l oa di ng the neces s a ry ontol ogy, we ca n i ns ta nti a te the
Autocompl eteHel per. Compl eti on res ul ts ca n fi rs t be retri eved when the i ndex ha s been rebui l t.
AutocompleteHelper helper = new AutocompleteHelper(manager);
while (!AutocompleteHelper.isIndexUpdateToDate(myOntology)) {
Thread.sleep(100);
}
Before retri evi ng a ny compl eti on res ul ts , we need to s et up a n Autocompl eteHel per.Opti ons object to pa s s to
the Autocompl eteHel per. Thes e opti ons control , a mongs t other thi ngs , how terms a re fetched a nd pres ented
a nd a l l ow a ddi ti ona l s ea rch cri teri a to be s peci fi ed. Mul ti pl e opti ons objects ca n be kept ha ndy a nd a ppl i ed
dependi ng on the context i n whi ch a utocompl ete i s needed.
A very us eful opti on i s the Concept Fi l ter, whi ch a l l ows a utocompl eti on to be l i mi ted to jus t i ns ta nces of a
pa rti cul a r concept. In the code s ni ppet bel ow, we l i mi t the s ea rch to i ns ta nces of the concept Pers on.
AutocompleteHelper.Options options = new AutocompleteHelper.Options();
Term concept = KAON2Manager.factory().constantIRI("http://www.ontoprise.de/
example#Person");
options.setConceptFilter(concept); // Only search instances of Person
A further condi ti on ca n be i mpos ed on the compl eti on res ul ts , where the va ri a bl e ?OBJ refers to the potenti a l
compl eti on s ugges ti on, tha t woul d, wi th no a ddi ti ona l fi l ter, be returned. Our exa mpl e fi l ter el i mi na tes
compl eti on s ugges ti ons for pers ons , who a re currentl y on va ca ti on (s ee the demo progra m for a nother
exa mpl e).
options.setAdditionalFilter(
"AND ?OBJ[<http://www.ontoprise.de/example#isOnVacation>->false]");
101
OntoBroker 6.3 Interfa ces to OntoBroker
In thi s s ecti on we ha ve s hown how ea s i l y the AutoCompl eteHel per ca n be us ed. For a pos s i bl e
i mpl ementa ti on, s ee the a tta ched progra m.
Opera ti on executi on i s s pl i t i nto pha s es , whos e begi nni ng a nd end a re reported; bes i des , opera ti on progres s
i s reported i n uni ts of work. Thi s a l l ows the devel oper to provi de feedba ck to the us er i n ca s e of i ntera cti ve
a ppl i ca ti ons , or to l og or otherwi s e record progres s a nd res ul ts of a l ong-runni ng opera ti on.
ProgressListenerDemo
The Demo project i s a s i mpl e i ntera cti ve a ppl i ca ti on tha t i mports the s el ected ontol ogy fi l e i nto OntoBroker.
Importi ng the 2MB ontol ogy fi l e bundl ed wi th the project ma kes the l a g a l rea dy a ppa rent.
Worker Thread
In order to keep the GUI res pons i ve s o tha t we ca n di s pl a y opera ti on progres s a nd l et the us er ca ncel the
runni ng opera ti on, the l ong runni ng opera ti on mus t execute i n a nother threa d (di fferent from the GUI threa d).
The demo a ppl i ca ti on us es the conveni ent Swi ngWorker cl a s s to do thi s .
new SwingWorker<Void, Void>() {
protected Void doInBackground() throws Exception {
try {
loader.importExistingOntology(f, listener);
} catch (Exception ignore) {}
return null;
}
}.execute();
102
OntoBroker 6.3 Interfa ces to OntoBroker
outputText("op completed");
setGuiState(false);
}
When i mpl ementi ng the i nterfa ce methods , cons i der tha t they wi l l be ca l l ed from a nother threa d. Therefore,
a ny ca l l s from wi thi n thes e methods mus t be threa d-s a fe or gua ra nteed to execute on the ri ght threa d.
Thi s code s ni ppet s hows how the demo a ppl i ca ti on ma kes s ure i t i s onl y modi fyi ng s ta te of GUI components
from wi thi n the GUI threa d.
private void setGuiState(final boolean isImporting) {
if (SwingUtilities.isEventDispatchThread()) {
...
buttonCancel.setVisible(isImporting);
} else {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setGuiState(isImporting);
}});}}
103
OntoBroker 6.3 Interfa ces to OntoBroker
As a next s tep, we extend our knowl edge ba s e by a ddi ng the cl a s s i c a mong ca rs , the Vol ks wa gen Beetl e, to
the 'Europe' ontol ogy. Thi s ti me, we ma ke us e of a conveni ence method of the Ontology cl a s s , tha t a l l ows
a ddi ng textua l l y s peci fi ed a xi oms di rectl y to a n ontol ogy. By us i ng the conveni ence method, i t i s no l onger
neces s a ry to s peci fy the modul e expl i ci tl y, a s i t i s i mpl i ed by the ontol ogy ( europeOnto).
// add Beetle to cars in Europe
// module implicit (one module per ontology!)
// namespace explicit as text
europeOnto.addAxioms("<http://example.org/cars#Beetle>[].");
For a ddi ng Mercury Couga r to the 'Ameri ca ' ontol ogy, we fol l ow the two-s tep a pproa ch a ga i n, fi rs t crea ti ng the
a xi om object us i ng a fa ctory method. Hence, the modul e needs to be s peci fi ed expl i ci tl y. However, us i ng a
di fferent overl oa d of the fa ctory method, we now pa s s the modul e a nd na mes pa ce a s s epa ra te a rguments .
The modul e ca n be s i mpl y retri eved by ca l l i ng the a ppropri a te method of the Ontology i ns ta nce. The
na mes pa ce ca n then be fi xed us i ng a Namespaces object, whi ch ha s the a bi l i ty to hol d mul ti pl e na mes pa ce
decl a ra ti ons a l ong wi th thei r res pecti ve prefi xes a nd one defa ul t na mes pa ce.
// add Cougar to cars in America
// module explicit as a Term
// namespace explicit, default using a Namespaces object
Namespaces ns = new Namespaces();
ns.setDefaultNamespace(carsNS); // "http://example.org/cars#"
ax = KAON2Manager.factory().axiom("Cougar[].", ns, americaOnto.getModule());
americaOnto.addAxiom(ax);
Si mi l a r to the previ ous exa mpl e, we a dd the ra bbi t to the 'a ni ma l s ' ontol ogy. Onl y thi s ti me we ma ke us e of a
non-defa ul t na mes pa ce. Therefore, the regi s tered na mes pa ce prefi x mus t a l s o a ppea r i n the textua l
defi ni ti on of the new a xi om.
// add Rabbit to animals in America
// module explicit as a Term
// namespace explicit, non-default using a prefix
ns.registerPrefix("an", animalsNS);
ax = KAON2Manager.factory().axiom("an#Rabbit[].", ns, europeOnto.getModule());
europeOnto.addAxiom(ax);
The ra bbi t concl udes our excurs i on to modul es a nd na mes pa ces i n the OntoBroker API.
104
OntoBroker 6.3 Interfa ces to OntoBroker
Exa mpl e:
To s ee the di fference, s ee the output of the fol l owi ng ObjectLogi c query
?- _unify(?X,1.0) AND _unify(?Y,"Hi") AND _unify(?Z,["a","b","c"]).
On the XML l evel , the res ul ts l ook l i ke thi s
105
OntoBroker 6.3 Interfa ces to OntoBroker
<queryResponse>
<queryKey>2</queryKey>
<variableNames><var>X</var><var>Y</var><var>Z</var></variableNames>
<result>
<repr>1.0</repr>
<repr>"Hi"</repr>
<repr>[a,b,c]</repr>
</result>
</queryResponse>
<queryResponse>
<queryKey>3</queryKey>
<variableNames><var>X</var><var>Y</var><var>Z</var></variableNames>
<result>
<term><d>1.0</d></term>
<term><s>"Hi"</s></term>
<term><list><item><s>a</s></item><item><s>b</s></item>
<item><s>c</s></item></list></term>
</result>
</queryResponse>
More deta i l s ca n be found i n the WSDL. The Depl oyment 106 s ecti on des cri bes how to a cces s the concrete
WSDL.
12.3.2 Deployment
OntoBroker us ua l l y runs a s a s ta nda l one s erver, but a ddi ti ona l l y provi des the fea tures des cri bed a bove on
a n embedded HTTP s erver. After i ns ta l l i ng the OntoBroker di s tri buti on, the onl y di fference i s the a ddi ti ona l
comma nd l i ne a rgument "-webs ervi ce". Thi s tel l s OntoBroker to s ta rt i ts embedded HTTP s erver. The s ocket
communi ca ti on i s s ti l l a va i l a bl e i n the s a me ma nner a s i n previ ous OntoBroker vers i ons . By defa ul t, the HTTP
s erver us es the port <8267>, but you ca n s peci fy i t expl i ci tl y i n the "OntoConfi g.prp" wi th the property
"Ws HttpPort"
To a cces s the WSDL, us e the fol l owi ng URL: http://<ontobrokerhost>:<wshttpport>/services/
ontobroker?wsdl
If the OntoBroker s erver i s runni ng on your l oca l ma chi ne a nd you a re us i ng the defa ul t port <8267>, the l i nk
i s : http://localhost:8267/services/ontobroker?wsdl
To open the HTTP cons ol e, us e the fol l owi ng URL: http://<ontobrokerhost>:<wshttpport>/
<Proxy balancer://mycluster>
BalancerMember ajp://localhost:9001 loadfactor=1
BalancerMember ajp://localhost:9002 loadfactor=1
# The below is sample how to add a hot standby
#BalancerMember ajp://1.2.3.6:8009 status=+H
</Proxy>
106
OntoBroker 6.3 Interfa ces to OntoBroker
For more deta i l s , s ee the ProxyPa s s Di recti ve documenta ti on a t http://httpd.a pa che.org/docs /2.2/mod/
mod_proxy.html .
3. Sta rt OntoBroker i ns ta nces :
a) Set the fol l owi ng pa ra meters i n the fi rs t i ns ta nce of OntoConfi g.prp:
WorkerName = ob1
AJP.Port = 9001
WebConsole = on
AJP = on
Then s ta rt the OntoBroker.
b) Set the fol l owi ng pa ra meters i n OntoConfi g.prp of the s econd i ns ta nce:
WorkerName = ob2
AJP.Port = 9002
WebConsole = on
AJP = on
Then s ta rt the OntoBroker.
Note:
For a producti on s erver do not forget to s ecure the Apa che s erver!
After Apa che i s s ta rted a s a l oa d ba l a ncer a nd the OntoBroker i ns ta nces a re a l s o runni ng a s wel l , the
webs ervi ce ca n be a cces s ed vi a a WSDL poi nti ng to the Apa che port e.g.:
http://localhost/services/ontobroker?wsdl (Apache on port 80)
i ns tea d of
http://localhost:9001/services/ontobroker?wsdl
(OntoBroker on port 9001, whi ch wi l l not work)
The webcons ol e i s a cces s i bl e vi a :
http://localhost/console/Console.html
For more i nforma ti on on the web cons ol e cl i ck here 36 .
Restrictions
Onl y s ta tel es s Web s ervi ces a re s upported. As one nega ti ve exa mpl e, the Sema nti c Gui de Web s ervi ce i s not
s upported a s i t ma i nl y cons i s ts of s ta teful opera ti ons . For the s a me rea s ons , the col l a bora ti on s erver a nd
remote API a re not a va i l a bl e.
107
OntoBroker 6.3 Interfa ces to OntoBroker
Operation Annotation
openQuery Sta rts eva l ua ti on of the query a nd returns the query key.
long queryKey = _client.openQuery(query, fullXml)
getNextQuer
yRes ul ts Retri eves the next res ul ts .
PagedQueryResults results = _client.getNextQueryResults(queryKey,
maxResults, maxWaitTimeInMs)
The number of the res ul ts returned i s res tri cted by two pa ra meters : No more tha n ma xRes ul ts
a re returned. If the ca l l wa i ts l onger tha n ma xWa i tTi meIs Ms mi l l i s econds , the ca l l returns the
res ul ts i t ha s col l ected duri ng thi s ti me s pa n. If the Pa gedQueryRes ul ts .i s Fi ni s hed() method
returns true, the query i s fi ni s hed a nd there a re no more res ul ts . The query i s a utoma ti ca l l y
cl os ed on the s erver s i de.
ca ncel Open Ca l l thi s opera ti on to ca ncel a n open query. If you do not retri eve a l l of the query res ul ts , i t i s
Query i mporta nt to ca l l thi s method a s the query i s s ti l l open on the s erver s i de a nd wi l l bl ock
res ources .
/**
* Marker interface for web services deployed together with OntoBroker
*/
@ExcludeAll
public interface OntoBrokerService {
}
@javax.jws.WebService(endpointInterface ="com.acme.mywebservice.MyItf")
public class MyService implements MyItf, OntoBrokerService {
private OntologyManager _ontologyManager;
Norma l l y a Web s ervi ce depl oyed i n OntoBroker needs a cces s to the ontol ogi es or the rea s oner. For thi s
purpos e, your webs ervi ce cl a s s s houl d reference the OntoBrokerServi ceMa na ger s ervi ce a nd remember the
Ontol ogyMa na ger on the bi nd opera ti on. In a ddi ti on you need to s peci fy the rel a ti ve a ddres s for publ i s hi ng
the Web s ervi ce endpoi nt.
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.acme.
mywebservice">
<implementation class="com.acme.mywebservice.MySvc"/>
<reference cardinality="1..1" interface="com.ontoprise.ontobroker.webservice.
OntoBrokerServiceManager" name="OntoBrokerServiceManager" policy="static" bind="
bindOntoBrokerServiceManager" />
<provide interface="com.ontoprise.ontobroker.webservice.OntoBrokerService"/>
</service>
<property name="address" type="String" value="/myservice"/>
</scr:component>
The res t i s s i mi l a r to the a bove des cri pti on for the bui l t-i n bundl e.
108
OntoBroker 6.3 Interfa ces to OntoBroker
Note:
The COM i nterfa ce i s no l onger s upported. Pl ea s e us e the webs ervi ce i nterfa ce i ns tea d (we provi de s a mpl e
Vi s ua l Studi o projects for C# a nd Vi s ua l Ba s i c).
using System;
using OntoBrokerWebserviceSample.OntoBroker;
namespace OntoBrokerWebserviceSample
{
/// <summary>
/// This is a sample how to use the OntoBroker 6.0 webservice with C#
/// It is assumed that this webservice has already been added to the project
/// using Project/Add Service Reference...
/// </summary>
class Program
{
static void Main(string[] args)
{
OntobrokerTypeClient client = new OntobrokerTypeClient();
string module = "<http://sample.ontoprise.de/ws>";
string suffix = "@" + module + ".";
109
OntoBroker 6.3 Interfa ces to OntoBroker
Console.Out.WriteLine();
Console.Out.WriteLine("Same query with paging");
Console.Out.WriteLine();
110
OntoBroker 6.3 Interfa ces to OntoBroker
/*
* Copyright (c) 2008-2010 ontoprise GmbH.
*/
package sample;
import java.util.List;
import com.ontoprise.schema.ontobroker.ws._2009._01.PagedQueryResults;
import com.ontoprise.schema.ontobroker.ws._2009._01.QueryResults;
import com.ontoprise.schema.ontobroker.ws._2009._01.WsTuple;
import com.ontoprise.services.OntobrokerSvcService;
import com.ontoprise.services.OntobrokerType;
/*
* This is a sample how to use the OntoBroker 6.0 webservice with Java 1.6 using JAX-
WS
*/
public class WebserviceClient {
String msg;
msg = client.command("insert Michael[age->15]" + suffix);
System.out.println(msg);
msg = client.command("insert John[age->18]" + suffix);
System.out.println(msg);
msg = client.command("insert Sandra[age->21]" + suffix);
System.out.println(msg);
System.out.println();
System.out.println("Same query with paging");
System.out.println();
111
OntoBroker 6.3 Interfa ces to OntoBroker
CustomerIDE/CodeExamples
com.ontoprise.ontobroker.examples.api provi des a n ecl i ps e-ba s ed envi ronment for devel opi ng own
OntoBroker extens i ons . It a l rea dy conta i ns code exa mpl es a nd uni t tes ts for bui l ti ns , comma nds , connectors ,
rewri ters a nd dyna mi c webs ervi ces .
112
OntoBroker 6.3 Interfa ces to OntoBroker
To i mpl ement thi s i nterfa ce, crea te a cl a s s l i ke the fol l owi ng exa mpl e
package com.acme.mypackage
import java.util.*
import com.ontoprise.ontobroker.api.extension.builtin.IBuiltin;
Pa cka ge thi s cl a s s together wi th your bui l ti n cl a s s es i n a JAR fi l e. You need to a dd a n OSGI conform META-INF/
MANIFEST.MF fi l e to the JAR.
META-INF/MANIFEST.MF (mi ni ma l i s ti c vers i on)
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyBuiltins
Bundle-SymbolicName: com.acme.mypackage
Bundle-Version: 1.0.0
Require-Bundle: com.ontoprise.ontobroker.base,com.ontoprise.ontobroker.datamodel
Import-Package: org.osgi.framework,org.osgi.service.component
Export-Package: com.acme.mypackage
Service-Component: OSGI-INF/component.xml
In a ddi ti on, to regi s ter the OSGI s ervi ce the s i mpl es t wa y i s to defi ne i t a s decl a ra ti ve s ervi ce i n a n OSGI-INF/
component.xml .
OSGI-INF/component.xml
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.acme.
mypackage">
<implementation class="mypackage.MyBuiltinsProvider"/>
<service>
<provide interface="com.ontoprise.ontobroker.kernel.builtinsystem.
BuiltinProvider"/>
</service>
</scr:component>
Al s o s ee the exa mpl e i n the Ecl i ps e project l oca ted a t $ONTOBROKER_HOME/i nterfa ces /devel opment/
CodeExa mpl es
113
OntoBroker 6.3 Interfa ces to OntoBroker
114
OntoBroker 6.3 Interfa ces to OntoBroker
115
OntoBroker 6.3 Interfa ces to OntoBroker
6. Dea cti va te the checkbox Create a plug-in using one of the templates.
7. Pres s Finish.
Now a dd OntoBroker dependenci es .
8. Sel ect META-INF/MANIFEST.MF a nd doubl e-cl i ck to open the edi tor.
9. Swi tch to ta b Dependencies.
116
OntoBroker 6.3 Interfa ces to OntoBroker
package com.acme.sample;
import java.util.BitSet;
import org.semanticweb.kaon2.api.KAON2Exception;
import org.semanticweb.kaon2.api.KAON2Manager;
import org.semanticweb.kaon2.api.OntologyLanguage;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.ontobroker.api.extension.builtin.IBuiltinContext;
import com.ontoprise.ontobroker.api.extension.builtin.IFunctionalBuiltin;
import com.ontoprise.ontobroker.api.extension.builtin.IGrounds;
import com.ontoprise.ontobroker.apibase.extension.builtin.BuiltinSpec;
import com.ontoprise.util.OntopriseConstants;
import com.ontoprise.util.TermUtilities2;
/**
* Example built-in which concats two strings.
*/
public class ConcatBuiltin implements IFunctionalBuiltin {
/**
* This method is called during the evaluation. We must first check
which of our four possible signatures applies and then either calculate
the result or
* check if a result is valid
*
* @param tuple the tuple which must be checked
* @throws InterruptedException if the process was interrupted
* @throws KAON2Exception if an error occurs
*/
@Override
public boolean evaluate(Term[] input, IGrounds grounds) throws
KAON2Exception, InterruptedException {
String str1 = TermUtilities2.getConstantValueAsString(input[0]);
String str2 = TermUtilities2.getConstantValueAsString(input[1]);
switch (grounds.getInt()) {
case IGrounds.FIRSTSECONDTHIRD:
return result == input[2]; // unify calculated and given
result?
case IGrounds.FIRSTSECOND:
input[2] = result;
return true;
default:
return false; // should never be reached because of
behaviour of isEvaluable
}
117
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* This method will be called after evaluation for cleanup purposes.
*
* NOTE: It is possible that this operator will be used again when the
same query object is openened again.
* init() won't be called a second time.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void evaluationFinished() throws KAON2Exception,
InterruptedException {
// This built-in has just one state, no need to set it back.
// It is used to set a built-in to the post-init() state.
}
/**
* Method to get informations about this built-in. This method has to
deliver a valid BuiltinSpec object
* after the constructor finishes, before init() has be called.
*
* @return BuiltinSpec object with informations about this built-in.
*/
public BuiltinSpec getInfo() {
BuiltinSpec.Builder builder = new BuiltinSpec.Builder(this, "obl:
reserved:myconcat", 3);
builder.setAllowedOntologyLanguages(OntologyLanguage.OBJECTLOGIC);
builder.setDescription("Concats two strings");
builder.setParameters("first string", "second string", "result");
return builder.build();
}
/**
* Initialisation of this built-in. This is done for the instance
before evaluation.
*
* @param context Contains additional Informations needed for some
built-ins
* @param args Term[] that contains the literal arguments.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void init(IBuiltinContext context, Term[] args) throws
KAON2Exception, InterruptedException {
// Nothing to do, as this built-in does not need any
initialization.
}
/**
* Method to determine if a certain grounds configuration is evaluable
.
* This method has to be usable context free, init() is called in an
other instance as
* isEvaluable will be called. All needed information should be
provided by the current
118
OntoBroker 6.3 Interfa ces to OntoBroker
* method arguments.
*
* @param grounds Object with grounding informations.
* @param variableInstantiations This BitSets has the instantiation of
all variables that occurs. Needed especially if partial-ground functions
are used.
* @param builtinContext BuiltinContext with additional context
informations
* @param args Literal arguments
* @return if this grounds are evaluable or not.
* @throws KAON2Exception Is thrown on Error
*/
public boolean isEvaluable(IGrounds grounds, BitSet
variableInstantiations, IBuiltinContext builtinContext, Term[] args)
throws KAON2Exception {
// first and second argument must be ground
switch (grounds.getInt()) {
case IGrounds.FIRSTSECONDTHIRD:
case IGrounds.FIRSTSECOND:
return true;
default:
return false;
}
}
com.acme.sample.BuiltinsProviderImpl.java
package com.acme.sample;
import java.util.ArrayList;
import java.util.Collection;
import com.ontoprise.ontobroker.api.extension.builtin.IBuiltin;
import com.ontoprise.ontobroker.kernel.builtinsystem.BuiltinProvider;
/**
* Provider for sample builtins
*/
public class BuiltinsProviderImpl implements BuiltinProvider {
@Override
public Collection<Class<? extends IBuiltin>> getBuiltins() {
ArrayList<Class<? extends IBuiltin>> list = new ArrayList<Class<? extends
IBuiltin>>();
// this bundle has only one built-in
list.add(ConcatBuiltin.class);
return list;
}
}
119
OntoBroker 6.3 Interfa ces to OntoBroker
120
OntoBroker 6.3 Interfa ces to OntoBroker
5. Export the Ja r fi l e by s el ecti ng the s a mpl e-bui l ti n project a nd choos e Export -> Deployable plug-ins and
fragments.
121
OntoBroker 6.3 Interfa ces to OntoBroker
Now you ha ve the s a mpl e_bui l ti ns _1.0.0.xxxx.ja r i n the di rectory D:\TEMP\pl ugi ns
122
OntoBroker 6.3 Interfa ces to OntoBroker
i mpl i es a functi ona l bui l t-i n, a nd a functi ona l bui l t-i n i mpl i es a fi l ter bui l t-i n. So a rel a ti ona l (or functi ona l )
bui l t-i n coul d be us ed i ns tea d of the other types , but thi s wi l l decrea s e the performa nce.
Al l bui l t-i ns ha ve to i mpl ement methods to gi ve i nforma ti on a bout the bui l t-i n, to s a y when i t ca n be
eva l ua ted a nd to do the eva l ua ti on. The a dva nta ge of us i ng of i nterfa ces i s tha t you now don't ha ve to
s ubcl a s s a fi xed cl a s s . The cons tructor mus t not ta ke pa ra meters , a nd the method getInfo() ha s to del i ver the
corres pondi ng Bui l ti nSpec a t a ny ti me, a fter a n i ns ta nce of the bui l t-i n wa s cons tructed.
It i s a good s tyl e of progra mmi ng to l et a l l bui l t-i ns (perha ps except connectors ) a ccept tupl es wi th a l l
a rguments ground. Pl ea s e cons i der thi s exa mpl e:
?- 2.0[_add(2.0)->?X] AND _square(?X,4.0).
To us e the s a me functi ona l i ty wi thout mul ti pl y a ccepti ng ground tupl es you woul d ha ve to do thi s :
?- 2.0[_add(2.0)->?X] AND _square("Y",4.0) AND _unify(?X,"Y").
In thi s ca s e thi s i s jus t one a ddi ti ona l bui l t-i n, but i t coul d decrea s e the performa nce, a s i n thi s ca s e the
res ul ts for Y a re 2 a nd -2, two ti mes the work for uni fy. Cons i der a bui l t-i n tha t woul d crea te more tha n 1000
res ul ts . Let's fi rs t ha ve a l ook a t a bui l t-i n tha t i s a l rea dy a va i l a bl e. The una ry bui l t-i n <IsNumber>; deci des
whether i ts a rgument i s a number or not. It i s ba s ed on <IFilterBuiltin>.
package com.ontoprise.builtin.filterbuiltin;
import java.util.BitSet;
import org.apache.log4j.Logger;
import org.semanticweb.kaon2.api.KAON2Exception;
import org.semanticweb.kaon2.api.OntologyLanguage;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.builtin.BuiltinContext;
import com.ontoprise.builtin.BuiltinSpec;
import com.ontoprise.builtin.builtin.BuiltinServices;
import com.ontoprise.builtin.interfaces.IFilterBuiltin;
import com.ontoprise.builtin.interfaces.IGrounds;
import com.ontoprise.util.OntopriseConstants;
/**
* Example builtin which checks if a given tuple is a number.
*
*/
public class IsNumberDemoBuiltin implements IFilterBuiltin {
/**
* Provide a no-argument constructor which does nothing - in this case.
*/
public IsNumberDemoBuiltin() { // Empty as nothing is to do for this built-in
}
/**
* This method is called during the evaluation. We must check for each input if
the condition ("isNumber") matches.
*
* @param input Term[] of always ground values.
* @return boolean if this input is true or not.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public boolean isTrue(Term[] input) throws KAON2Exception, InterruptedException {
try {
// Here we always get a term array with arity 1 (this is what we
specified in getInfo()).
if (BuiltinServices.isNumber(input[0])) {
123
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* This method will be called after evaluation for cleanup purposes.
*
* NOTE: It is possible that this operator will be used again when the same query
object is openened again.
* init() won't be called a second time.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void evaluationFinished() throws KAON2Exception, InterruptedException {
// This built-in has just one state, no need to set it back.
// It is used to set a built-in to the post-init() state.
}
/**
* Method to get informations about this built-in. This method has to deliver a
valid BuiltinSpec object
* after the constructor finishes, before init() has be called.
*
* @return BuiltinSpec object with informations about this built-in.
*/
@Override
public BuiltinSpec getInfo() {
BuiltinSpec.Builder builder = new BuiltinSpec.Builder(this, "isnumberdemo",
1);
builder.setAllowedOntologyLanguages(OntologyLanguage.F_LOGIC);
builder.setDescription("is X a number");
builder.setParameters("X");
return builder.build();
}
/**
* Initialisation of this built-in. This is done for the instance before
evaluation.
*
* @param context Contains additional Informations needed for some built-ins
* @param args Term[] that contains the literal arguments.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void init(BuiltinContext context, Term[] args) throws KAON2Exception,
InterruptedException {
// Nothing to do, as this built-in does not need any initialization.
}
/**
* Method to determine if a certain grounds configuration is evaluable.
* This method has to be usable context free, init() is called in an other
instance as
124
OntoBroker 6.3 Interfa ces to OntoBroker
Now ta ke a l ook a t Mul ti pl yDemoBui l ti n. It i s a functi ona l bui l t-i n, s o i t ca n del i ver one res ul t a t mos t.
package com.ontoprise.builtin.functionalbuiltin;
import java.util.BitSet;
import org.apache.log4j.Logger;
import org.semanticweb.kaon2.api.KAON2Exception;
import org.semanticweb.kaon2.api.KAON2Manager;
import org.semanticweb.kaon2.api.OntologyLanguage;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.builtin.BuiltinContext;
import com.ontoprise.builtin.BuiltinSpec;
import com.ontoprise.builtin.Grounds;
import com.ontoprise.builtin.builtin.BuiltinServices;
import com.ontoprise.builtin.interfaces.IFunctionalBuiltin;
import com.ontoprise.builtin.interfaces.IGrounds;
import com.ontoprise.util.OntopriseConstants;
/**
* Example built-in which multiplies two numbers.
*
*/
public class MultiplyDemoBuiltin implements IFunctionalBuiltin {
protected static Logger _log = Logger.getLogger(OntopriseConstants.CORE_LOG);
/**
* Provide a no-argument constructor which needs nothing to do for this built-
in.
*/
public MultiplyDemoBuiltin() { // Empty as nothing is to do for this built-in
}
/**
* This method is called during the evaluation. We must first check which of our
four possible signatures applies and then either calculate the result or
* check if a result is valid
*
* @param tuple the tuple which must be checked
* @throws InterruptedException if the process was interrupted
* @throws KAON2Exception if an error occurs
*/
125
OntoBroker 6.3 Interfa ces to OntoBroker
@Override
public boolean evaluate(Term[] input, IGrounds grounds) throws KAON2Exception,
InterruptedException {
try {
switch (grounds.getInt()) {
case IGrounds.FIRSTSECONDTHIRD:
// All three positions are ground. This means we must check if
"position 0" multiplied with "position 1"
// equals the "position 2" value. If this is true we send away
the received tuple.
double op1 = BuiltinServices.getNumber(input[0]);
double op2 = BuiltinServices.getNumber(input[1]);
double result = BuiltinServices.getNumber(input[2]);
if (op1 * op2 == result) {
return true;
}
break;
case IGrounds.FIRSTSECOND: {
// First and second position is ground. We must multiply the
first with the second position
// and send away the result tuple.
op1 = BuiltinServices.getNumber(input[0]);
op2 = BuiltinServices.getNumber(input[1]);
// third argument must be filled with the result
result = op1 * op2;
// Create and send away the new tuple.
input[2] = KAON2Manager.factory().constantDouble(result);
return true;
}
case IGrounds.FIRSTTHIRD: {
// First and third position is ground. First position multiplied
with second position
// must be equal to the third position. We need to calculate the
second position.
op1 = BuiltinServices.getNumber(input[0]);
op2 = BuiltinServices.getNumber(input[1]);
// third argument must be filled with the result
result = op2 / op1;
// Create and send away the new tuple.
input[1] = KAON2Manager.factory().constantDouble(result);
return true;
}
case IGrounds.SECONDTHIRD: {
// Second and third position is ground. We must calculate the
first position.
op1 = BuiltinServices.getNumber(input[1]);
op2 = BuiltinServices.getNumber(input[2]);
// third argument must be filled with the result
result = op2 / op1;
// Create and send away the new tuple.
input[0] = KAON2Manager.factory().constantDouble(result);
return true;
}
}
} catch (Exception e) {
_log.error("Invalid input", e);
}
return false;
}
/**
* This method will be called after evaluation for cleanup purposes.
*
126
OntoBroker 6.3 Interfa ces to OntoBroker
* NOTE: It is possible that this operator will be used again when the same query
object is openened again.
* init() won't be called a second time.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void evaluationFinished() throws KAON2Exception, InterruptedException {
// This built-in has just one state, no need to set it back.
// It is used to set a built-in to the post-init() state.
}
/**
* Method to get informations about this built-in. This method has to deliver a
valid BuiltinSpec object
* after the constructor finishes, before init() has be called.
*
* @return BuiltinSpec object with informations about this built-in.
*/
public BuiltinSpec getInfo() {
BuiltinSpec.Builder builder = new BuiltinSpec.Builder(this, "multiplydemo",
3);
builder.setAllowedOntologyLanguages(OntologyLanguage.F_LOGIC);
builder.setDescription("multiplydemo");
builder.setParameters("first parameter", "second parameter", "result");
return builder.build();
}
/**
* Initialisation of this built-in. This is done for the instance before
evaluation.
*
* @param context Contains additional Informations needed for some built-ins
* @param args Term[] that contains the literal arguments.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void init(BuiltinContext context, Term[] args) throws KAON2Exception,
InterruptedException {
// Nothing to do, as this built-in does not need any initialization.
}
/**
* Method to determine if a certain grounds configuration is evaluable.
* This method has to be usable context free, init() is called in an other
instance as
* isEvaluable will be called. All needed information should be provided by the
current
* method arguments.
*
* @param grounds Object with grounding informations.
* @param variableInstantiations This BitSets has the instantiation of all
variables that occurs. Needed especially if partial-ground functions are used.
* @param builtinContext BuiltinContext with additional context informations
* @param args Literal arguments
* @return if this grounds are evaluable or not.
* @throws KAON2Exception Is thrown on Error
*/
public boolean isEvaluable(IGrounds grounds, BitSet variableInstantiations,
BuiltinContext builtinContext, Term[] args) throws KAON2Exception {
// There are four different signatures that can be evaluated by this built-
in.
// It is just necessary that at least three of the arguments are ground.
127
OntoBroker 6.3 Interfa ces to OntoBroker
// This method has not to check the input type, just the grounds.
switch (grounds.getInt()) {
case Grounds.FIRSTSECONDTHIRD: {
return true;
}
case Grounds.FIRSTSECOND: {
return true;
}
case Grounds.FIRSTTHIRD: {
return true;
}
case Grounds.SECONDTHIRD: {
return true;
}
default:
return false;
}
}
Ta ke a l ook a t a rel a ti ona l bui l t-i n. Squa re ei ther computes X² for i nput X, or i t returns s qrt(X) a nd -s qrt(X):
package com.ontoprise.builtin.relationalbuiltin.mathematics;
import java.util.BitSet;
import org.apache.log4j.Logger;
import org.semanticweb.kaon2.api.KAON2Exception;
import org.semanticweb.kaon2.api.KAON2Manager;
import org.semanticweb.kaon2.api.OntologyLanguage;
import org.semanticweb.kaon2.api.logic.Constant;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.builtin.BuiltinContext;
import com.ontoprise.builtin.BuiltinSpec;
import com.ontoprise.builtin.interfaces.IGrounds;
import com.ontoprise.builtin.interfaces.IReceiver;
import com.ontoprise.builtin.interfaces.IRelationalBuiltin;
import com.ontoprise.util.OntopriseConstants;
/**
* Provide a no-argument constructor which needs nothing to do for this built-
in.
*/
public Square() {
// Empty as nothing is to do for this built-in
}
/**
* Method to start evaluation. After this method has finished, any results have
* to be sended by the IReceiver, no additional data is allowed.
*
* @param input Term[] with input tuples.
* @param grounds IGrounds object with grounding informations.
* @param destination Receiver to send every result to.
* Use destination.send(Term[] resultbuffer) to send results away.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
128
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* This method will be called after evaluation for cleanup purposes.
*
* NOTE: It is possible that this operator will be used again when the same
* query object is openened again. init() won't be called a second time.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void evaluationFinished() throws KAON2Exception, InterruptedException {
// This built-in has just one state, no need to set it back.
129
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* Method to get informations about this built-in. This method has to deliver a
* valid BuiltinSpec object after the constructor finishes, before init() has
* be called.
*
* @return BuiltinSpec object with informations about this built-in.
*/
@Override
public BuiltinSpec getInfo() {
BuiltinSpec.Builder builder = new BuiltinSpec.Builder(this, "square", 2);
builder.setAllowedOntologyLanguages(OntologyLanguage.F_LOGIC);
builder.setDescription("X^2 or sqrt(X) and -sqrt(X), depending of the
grounds");
builder.setParameters("X", "X^2");
return builder.build();
}
/**
* Initialisation of this built-in. This is done for the instance before
evaluation.
*
* @param context Contains additional Informations needed for some built-ins
* @param args Term[] that contains the literal arguments.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void init(BuiltinContext context, Term[] args) throws KAON2Exception,
InterruptedException {
// Nothing to do, as this built-in does not need any initialization.
}
/**
* Method to determine if a certain grounds configuration is evaluable. This
method has to be
* usable context free, init() is called in an other instance as
* isEvaluable will be called. All needed information should be provided by the
current method arguments.
*
* @param grounds Object with grounding informations.
* @param variableInstantiations This BitSets has the instantiation of all
variables that occurs.
* Needed especially if partial-ground functions are used.
* @param builtinContext BuiltinContext with additional context informations
* @param args Literal arguments
* @return if this grounds are evaluable or not.
* @throws KAON2Exception Is thrown on Error
*/
@Override
public boolean isEvaluable(IGrounds grounds, BitSet variableInstantiations,
BuiltinContext builtinContext, Term[] args) throws KAON2Exception {
// There are four different signatures that can be evaluated by this built-
in.
// It is just necessary that at least three of the arguments are ground.
// This method has not to check the input type, just the grounds.
switch (grounds.getInt()) {
case 1: // first argument is ground, binary: 01
return true;
case 2: // second argument is ground, binary: 10
return true;
130
OntoBroker 6.3 Interfa ces to OntoBroker
package com.ontoprise.builtin.functionalbuiltin;
import java.util.BitSet;
import org.apache.log4j.Logger;
import org.semanticweb.kaon2.api.KAON2Exception;
import org.semanticweb.kaon2.api.KAON2Manager;
import org.semanticweb.kaon2.api.OntologyLanguage;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.builtin.BuiltinContext;
import com.ontoprise.builtin.BuiltinSpec;
import com.ontoprise.builtin.Grounds;
import com.ontoprise.builtin.builtin.BuiltinServices;
import com.ontoprise.builtin.interfaces.IFunctionalBuiltin;
import com.ontoprise.builtin.interfaces.IGrounds;
import com.ontoprise.util.OntopriseConstants;
/**
* Example built-in which multiplies two numbers.
*
*/
public class MultiplyDemoBuiltin implements IFunctionalBuiltin {
protected static Logger _log =
Logger.getLogger(OntopriseConstants.CORE_LOG);
/**
* Provide a no-argument constructor which needs nothing to do for this built-in.
*/
public MultiplyDemoBuiltin() { // Empty as nothing is to do for this built-in
}
/**
* This method is called during the evaluation. We must first check which of our
four possible signatures applies and then either calculate the result or
* check if a result is valid
*
* @param tuple the tuple which must be checked
* @throws InterruptedException if the process was interrupted
* @throws KAON2Exception if an error occurs
*/
@Override
public boolean evaluate(Term[] input, IGrounds grounds) throws KAON2Exception,
InterruptedException {
try {
switch (grounds.getInt()) {
case IGrounds.FIRSTSECONDTHIRD:
// All three positions are ground. This means we must check if
"position 0" multiplied with "position 1"
131
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* This method will be called after evaluation for cleanup purposes.
*
132
OntoBroker 6.3 Interfa ces to OntoBroker
* NOTE: It is possible that this operator will be used again when the same query
object is openened again.
* init() won't be called a second time.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void evaluationFinished() throws KAON2Exception, InterruptedException {
// This built-in has just one state, no need to set it back.
// It is used to set a built-in to the post-init() state.
}
/**
* Method to get informations about this built-in. This method has to deliver a
valid BuiltinSpec object
* after the constructor finishes, before init() has be called.
*
* @return BuiltinSpec object with informations about this built-in.
*/
public BuiltinSpec getInfo() {
BuiltinSpec.Builder builder = new BuiltinSpec.Builder(this, "multiplydemo",
3);
builder.setAllowedOntologyLanguages(OntologyLanguage.F_LOGIC);
builder.setDescription("multiplydemo");
builder.setParameters("first parameter", "second parameter", "result");
return builder.build();
}
/**
* Initialisation of this built-in. This is done for the instance before
evaluation.
*
* @param context Contains additional Informations needed for some built-ins
* @param args Term[] that contains the literal arguments.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
public void init(BuiltinContext context, Term[] args) throws KAON2Exception,
InterruptedException {
// Nothing to do, as this built-in does not need any initialization.
}
/**
* Method to determine if a certain grounds configuration is evaluable.
* This method has to be usable context free, init() is called in an other
instance as
* isEvaluable will be called. All needed information should be provided by the
current
* method arguments.
*
* @param grounds Object with grounding informations.
* @param variableInstantiations This BitSets has the instantiation of all
variables that occurs. Needed especially if partial-ground functions are used.
* @param builtinContext BuiltinContext with additional context informations
* @param args Literal arguments
* @return if this grounds are evaluable or not.
* @throws KAON2Exception Is thrown on Error
*/
public boolean isEvaluable(IGrounds grounds, BitSet variableInstantiations,
BuiltinContext builtinContext, Term[] args) throws KAON2Exception {
// There are four different signatures that can be evaluated by this built-
in.
// It is just necessary that at least three of the arguments are ground.
133
OntoBroker 6.3 Interfa ces to OntoBroker
// This method has not to check the input type, just the grounds.
switch (grounds.getInt()) {
case Grounds.FIRSTSECONDTHIRD: {
return true; // all arguments are ground
}
case Grounds.FIRSTSECOND: {
return true; // the third argument is not ground
}
case Grounds.FIRSTTHIRD: {
return true; // the second argument is not ground
}
case Grounds.SECONDTHIRD: {
return true; // the first argument is not ground
}
default:
return false; // cannot be evaluated
}
}
package com.ontoprise.builtin.iconnector;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.BitSet;
import org.apache.log4j.Logger;
import org.semanticweb.kaon2.api.KAON2Exception;
import org.semanticweb.kaon2.api.KAON2Manager;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.builtin.BuiltinContext;
import com.ontoprise.builtin.BuiltinSpec;
import com.ontoprise.builtin.interfaces.IConnector;
import com.ontoprise.builtin.interfaces.IGrounds;
import com.ontoprise.builtin.interfaces.IReceiver;
import com.ontoprise.util.OntopriseConstants;
import com.ontoprise.util.TermUtilities;
134
OntoBroker 6.3 Interfa ces to OntoBroker
import com.ontoprise.utils.StringUtil;
/**
* Example connector which reads information from a URL. A connector receives a list
of tuples
* and sends away a list of tuples. This demo connector reads the content of each URL
and determines
* the number of characters for each URL.
*
*/
public class CountCharactersOfURLsConnector implements IConnector {
private IReceiver _destination;
private ArrayList _input;
protected static Logger _log = Logger.getLogger(OntopriseConstants.CORE_LOG);
// {{STRING, VARIABLE}};
/**
* Provide a no-argument constructur which sets the properties of the connector.
*/
public CountCharactersOfURLsConnector() {
}
/**
* Method to get informations about this built-in. This method has to deliver a
valid BuiltinSpec object
* after the constructor finishes, before init() has be called.
*
* @return BuiltinSpec object with informations about this built-in.
*/
@Override
public BuiltinSpec getInfo() {
BuiltinSpec.Builder builder = new BuiltinSpec.Builder(this,
"countCharactersOfURLs", 2);
builder.setDescription("gets number of characters of different URI-
documents");
builder.setParameters("URI","number of characters");
return builder.build();
}
/**
* Method to signal that several input tuples will arrive. Between start() and
stop() the grounds will not change.
*
* @param grounds IGrounds object with grounding informations of all following
input tuples.
* @param destination Receiver for each result created.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void start(IGrounds grounds, IReceiver destination) throws KAON2Exception,
InterruptedException {
_destination = destination;
_input = new ArrayList(200);
}
/**
* This method will provide the input tuples. May just called between start() and
stop().
*
* @param input Term[] with input.
* @throws KAON2Exception Is thrown on Error
135
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* Method to signal that no further input will follow within this block.
* (Although there could be another start() / stop() cycle.)
* All what has to be done to deliver results has to be done here if it was not
done before.
* After this method has finished, any results have to be sended by the
IReceiver, no additional
* data is allowed.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void stop() throws KAON2Exception, InterruptedException {
Term[] newArguments = new Term[2];
for (Term[] arguments: _input) {
String url = StringUtil.unQuote((String) TermUtilities.getValue(arguments
[0]));
int numOfCharacters = openAndReadURL(url);
newArguments[0] = arguments[0];
newArguments[1] = KAON2Manager.factory().constant(new Double
(numOfCharacters));
_destination.send(newArguments);
}
}
/**
* Opens a URL, reads the content and counts the characters.
*
* @param urlString the URL
* @return the number of characters of the document at
the URL location
*/
private int openAndReadURL(String urlString) {
int numOfCharacters = 0;
try {
URL url = new URL(urlString);
InputStreamReader isr = new InputStreamReader(url.openStream());
BufferedReader in = new BufferedReader(isr);
String line;
while ((line = in.readLine()) != null) {
numOfCharacters += line.length();
}
in.close();
} catch (MalformedURLException ex) {
_log.error("DemoConnector received invalid URL: " + urlString);
} catch (IOException ex) {
_log.error("DemoConnector got an IOException while reading the URL '" +
urlString + "'.", ex);
}
return numOfCharacters;
}
/**
136
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* This method will be called after evaluation for cleanup purposes.
*
* NOTE: It is possible that this operator will be used again when the same query
object is openened again.
* init() won't be called a second time.
*
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void evaluationFinished() throws KAON2Exception, InterruptedException {
// This built-in has just one state, no need to set it back.
// It is used to set a built-in to the post-init() state.
// btw.: This is not a dispose method, don't use it to clean up. Maybe it
won't be called.
}
/**
* Initialisation of this built-in. This is done for the instance before
evaluation.
*
* @param context Contains additional Informations needed for some built-ins
* @param args Term[] that contains the literal arguments.
* @throws KAON2Exception Is thrown on Error
* @throws InterruptedException Is thrown on Interruption
*/
@Override
public void init(BuiltinContext context, Term[] args) throws KAON2Exception,
InterruptedException {
}
/**
* Method to determine if a certain grounds configuration is evaluable.
* This method has to be usable context free, init() is called in an other
instance as
* isEvaluable will be called. All needed information should be provided by the
current
* method arguments.
*
137
OntoBroker 6.3 Interfa ces to OntoBroker
Exa mpl es :
<- string2number("35",35.0).
wi l l res ul t i n "true". The query
<- string2number("35.0",35.0).
wi l l return "true", too.
But thi s query
<- string2number(X,35.0) AND equal(X,"35").
wi l l return "fa l s e". The rea s on i s tha t X wi l l be bound wi th "35.0" by the s tri ng2number bui l ti n a nd the equa l
bui l ti n correctl y eva l ua tes tha t the s tri ng "35.0" i s not equa l to the s tri ng "35". But i f the opti mi zer
"Equa l Uni fyRewri ter" i s turned on i t wi l l el i mi na te the equa l bui l ti n a nd wi l l rewri te thi s rul e to
<- string2number("35",35.0).
a nd thi s rul e wi l l a ga i n return "true".
138
OntoBroker 6.3 Interfa ces to OntoBroker
We s upport fl oa ti ng poi nt numbers a ccordi ng to IEEE 754 (equi va l ent to Ja va 's doubl e da ta type). Fl oa ti ng
poi nt numbers cover a ra nge from:
4.94065645841246544e-324 to 1.79769313486231570e+308
both pos i ti ve a nd nega ti ve.
package com.ontoprise.rewriter.example;
import org.semanticweb.kaon2.api.KAON2Manager;
import org.semanticweb.kaon2.api.logic.Literal;
import org.semanticweb.kaon2.api.logic.PredicateSymbol;
import org.semanticweb.kaon2.api.logic.Rule;
import org.semanticweb.kaon2.api.logic.Term;
import com.ontoprise.exception.DataModelException;
import com.ontoprise.obfuscation.ExcludePublicMembers;
import com.ontoprise.rewriter.AbstractRuleRewriter;
/**
* This is the method which is called during the rewriting process. This method
is called for each
* of the rules which are relevant for the current query.
* <p>
* If you do not want to touch a rule just return the original rule.
* </p>
*/
139
OntoBroker 6.3 Interfa ces to OntoBroker
/**
* Checks if the given rule contains a "less" literal.
*
* @param rule the rule to be checked
* @return <tt>true</tt> if it contains a "less" literal,
<tt>false</tt> otherwise.
*/
private boolean containsLessLiterals(Rule rule) {
for (Literal bodyLiteral: rule.getBodyLiterals()) {
if (isLessLiteral(bodyLiteral)) {
return true;
}
}
return false;
}
/**
* Is the given literal a "less" literal?
*
* @param literal the literal to be checked
* @return <tt>true</tt> if the given literal is a "less" literal,
<tt>false</tt> otherwise.
*/
private boolean isLessLiteral(Literal literal) {
PredicateSymbol predicate = literal.getPredicateSymbol();
if (predicate.getName().equals("less") && predicate.getArity() == 2) {
return true;
} else {
return false;
}
}
/**
* Returns a new rule where all occurences of "less" are replaced with "greater".
*
* @param rule the rule with the "less" literals
* @return the new rule (with the "greater" literals)
*/
private Rule exchangeBodyByGreater(Rule rule) {
Literal[] newBodyLiterals = new Literal[rule.getBodyLength()];
int index = 0;
for (Literal bodyLiteral: rule.getBodyLiterals()) {
if (isLessLiteral(bodyLiteral)) {
// Create a new "greater" literal.
PredicateSymbol greaterPredicate = KAON2Manager.factory().
predicateSymbol("greater", 2);
Term[] newArguments = bodyLiteral.getArguments().clone();
Literal greaterLiteral = KAON2Manager.factory().literal(bodyLiteral.
isPositive(), greaterPredicate, newArguments);
newBodyLiterals[index] = greaterLiteral;
} else {
// Just reuse the old literal.
newBodyLiterals[index] = bodyLiteral;
}
index++;
}
140
OntoBroker 6.3 Interfa ces to OntoBroker
After you ha ve devel oped your own rewri ter you ca n try i t out by compi l i ng i t, putti ng i t i nto a JAR l i bra ry a nd
pl a ci ng tha t l i bra ry to the "rewri ters " fol der of your OntoBroker i ns ta l l a ti on. When OntoBroker s ta rts you
s houl d s ee a mes s a ge tha t the rewri ter wa s l oa ded a nd i ni ti a l i zed.
The procedure i s a na l og to the a bove des cri pti on for the bui l ti n JAR fi l e. Onl y the decl a ra ti ve s ervi ce
defi ni ti on fi l e i s s hown here.
OSGI-INF/component.xml
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.acme.
myrewriters">
<implementation class="mypackage.MyRewritersProvider"/>
<service>
<provide interface="com.ontoprise.api.rewriter.RewriterProvider"/>
</service>
</scr:component >
/**
* Marker interface for web services deployed together with OntoBroker
*/
@ExcludeAll
public interface OntoBrokerService {
}
@javax.jws.WebService(endpointInterface ="com.acme.mywebservice.MyItf")
public class MyService implements MyItf, OntoBrokerService {
private OntologyManager _ontologyManager;
Norma l l y a Web s ervi ce depl oyed i n OntoBroker needs a cces s to the ontol ogi es or the rea s oner. For thi s
purpos e, your webs ervi ce cl a s s s houl d reference the OntoBrokerServi ceMa na ger s ervi ce a nd remember the
Ontol ogyMa na ger on the bi nd opera ti on. Addi ti ona l l y you need to s peci fy the rel a ti ve a ddres s for publ i s hi ng
the Web s ervi ce endpoi nt.
141
OntoBroker 6.3 Interfa ces to OntoBroker
The res t i s s i mi l a r to the a bove des cri pti on for the bui l t-i n bundl e.
12.6 UIMA
Definition:
UIMA - Uns tructured Informa ti on Ma na gement Archi tecture - i s a techni ca l i nfra s tructure for proces s i ng
na tura l l a ngua ge documents . It ha s been i ni ti a ted by IBM a nd ha s become a n OASIS s ta nda rd.
"Uns tructured i nforma ti on ma y be defi ned a s the di rect product of huma n communi ca ti on. Exa mpl es
i ncl ude na tura l l a ngua ge documents , ema i l , s peech, i ma ges a nd vi deo. It i s i nforma ti on tha t wa s not
s peci fi ca l l y encoded for ma chi nes to proces s but ra ther a uthored by huma ns for huma ns to unders ta nd. We
s a y i t i s “uns tructured” beca us e i t l a cks expl i ci t s ema nti cs (“s tructure”) requi red for a ppl i ca ti ons to
i nterpret the i nforma ti on a s i ntended by the huma n a uthor or requi red by the end-us er a ppl i ca ti on. "
Source: http://docs .oa s i s -open.org/ui ma /v1.0/ui ma -v1.0.html
UIMA provi des a n extens i bl e type s ys tem whi ch i ncl udes pri mi ti ve types l i ke i ntegers or s tri ngs . In a ddi ti on
there i s a bui l t-i n type for (textua l ) a nnota ti ons whi ch cons i s ts of a s ta rt a nd a n end i ndex wi thi n a text.
Us ua l l y ea ch a na l ys i s engi ne extends the type s ys tem by one or more new types . For exa mpl e, a new type
'PhoneNumber' ca n be a dded a s a s ub type of the a nnota ti on type. The a na l ys i s engi ne then a nnota tes the
text by crea ti ng new i ns ta nces of PhoneNumber, i ncl udi ng the s ta rt a nd end i ndex i n the text tha t the covered
text i s a textua l repres enta ti on of a phone number.
Ea ch type ma y ha ve a s s oci a ted fea tures . Thi s i s a fi el d for ea ch i ns ta nce of a type tha t conta i ns a pa rti cul a r
pa rt of i nforma ti on. For exa mpl e, the s ta rt a nd the end i ndex a re fea tures of the a nnota ti on type. An a na l ys i s
engi ne ca n defi ne new fea tures on i ts types , s o the PhoneNumber type coul d ha ve a fea ture
'norma l i zedNumber' whi ch conta i ns a norma l i zed vers i on of the phone number found i n the text, for exa mpl e
by removi ng s pa ces .
For more i nforma ti on a bout UIMA ta ke a l ook a t http://ui ma .a pa che.org/documenta ti on.html
142
OntoBroker 6.3 Interfa ces to OntoBroker
143
OntoBroker 6.3 Rol e-Ba s ed Securi ty
13 Role-Based Security
OntoBroker provi des rol e-ba s ed s ecuri ty fea tures whi ch a l l ow you to:
Us e exi s ti ng s ecuri ty i nfra s tructures (e.g. LDAP, Acti veDi rectory)
Gi ve rol es rea d/wri te a cces s to i ndi vi dua l ontol ogi es (modul es )
Res tri ct the a cces s to OntoBroker s erver comma nds
OntoBroker i s us i ng Apa che Ki for the s ecuri ty. See http://i ncuba tor.a pa che.org/ki / for further deta i l s a bout
thi s project a nd the fea tures i t provi des .
Exa mpl e:
:- module = $security.
:- importmodule $'security-core'.
Joe:User[hasRole->ResearchAndDevelopmentMember].
Jane:User[hasRole->HumanResourcesMember].
ResearchAndDevelopmentMember:Role[
hasReadPermission->Developers].
ControllingMember:Role[
hasReadPermission->Salaries;
hasWritePermission->Salaries].
Thi s mea ns
Joe ha s the rol e "Res ea rchAndDevel opmentMember" a nd ha s rea d permi s s i on to the modul e
"Devel opers " (whi ch proba bl y conta i ns i nforma ti on a bout other devel opers , thei r projects a nd fa vori te
progra mmi ng l a ngua ges ).
Ja ne ha s the rol e "Huma nRes ources Member". So s he ha s a cces s to the "Sa l a ri es " modul e whi ch
conta i ns i nteres ti ng i nforma ti on a bout the s a l a ri es of a l l peopl e worki ng i n the compa ny.
Rea d more a bout permi s s i ons here 152 .
Now cons i der tha t Joe i s i nteres ted i n the s a l a ri es of the other devel opers i n hi s tea m. He wi l l execute
?X ?- ?X:Developer@Developers AND ?X[hasSalary->?Y]@Salaries.
The fi rs t pa rt of thi s query i s OK: He ha s the ri ghts to a cces s the "Devel opers " modul e. But the s econd pa rt of
the query i s not OK: He does not ha ve the requi red rea d a cces s ri ghts to modul e "Sa l a ri es ", s o he gets no
a ns wers .
13.2 Realms
A rea l m i s ba s i ca l l y a res ource whi ch i s a bl e to a uthenti ca te us ers . Apa che Ki (a nd therefore OntoBroker)
s upport the fol l owi ng rea l ms :
JDBC realm (a l l ows to us e a SQL da ta ba s e for s tori ng us ers a nd pa s s words )
LDAP realm
ActiveDirectory realm
OntoBroker a l s o provi des i ts own rea l m: SecurityModuleRealm. Thi s rea l m i s us i ng a n ontol ogy (wri tten i n
ObjectLogi c) for s peci fyi ng us ers , rol es a nd permi s s i ons to modul es . It a l s o a l l ows you to crea te powerful
rul es (e.g. a l l us ers wi th rea d permi s s i ons on modul e A a l s o ha ve rea d permi s s i ons on modul e B).
144
OntoBroker 6.3 Rol e-Ba s ed Securi ty
Exam ple:
As s umi ng you ha ve the fol l owi ng modul e
:- default prefix = "http://company.com/".
:- module module1.
boss[name->"TheBoss"].
user1:User[hasRole->role1].
Thi s mea ns us er1 ha s rea d/wri te permi s s i ons on the na me property a nd rea d permi s s i on on the na me2
permi s s i on.
If you wa nt to a l l ow a l l properti es , you ca n us e "*":
readAnyProperties:Role[hasPropertyReadPermission-> "*"].
Thi s mea ns tha t a member of rol e rea dAnyProperti es ca n rea d a l l properti es .
Permi s s i ons on properti es a re not i nheri ted a cros s the property hi era rchy. Permi s s i ons need to be s et for
every s i ngl e property.
145
OntoBroker 6.3 Rol e-Ba s ed Securi ty
Exam ple:
If a us er ha s rea d permi s s i ons for property a , but no rea d permi s s i ons for property b, a nd b::a , then the query
?- ?X[a->?Y].
a l s o returns the va l ues for property b.
There i s a bui l t-i n _isPropertyPermitted/2 to expl i ci tl y check the permi s s i on for a property.
Exam ples:
?- _isPropertyPermitted(<http://company.com/name>, read). // check read
permission for property <http://company.com/name>
13.6 Authentication/Login
If OntoBroker i s confi gured for a cces s control , a us er ha s to l ogi n. The gi ven us erna me a nd pa s s word i s then
us ed by the s ecuri ty ba ckend to veri fy the i denti ty. When s ucces s ful l y a uthenti ca ted, the us er recei ves a ti cket
whi ch a l l ows hi m to execute a ny OntoBroker comma nd (dependi ng on hi s ri ghts )
146
OntoBroker 6.3 Rol e-Ba s ed Securi ty
Properties Realm
The s i mpl es t s cena ri o i s to defi ne us ers , thei r pa s s words a nd rol es i n a text fi l e. For thi s s cena ri o the XML
fi l e l ooks l i ke:
<source lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <beans>
<bean id="OntoBrokerSecurityManagerConfig" class="com.ontoprise.security.
OntoBrokerSecurityManagerConfig">
<property name="realms">
<list>
<ref local="PropertiesRealm"/>
</list>
</property>
<property name="authenticationStrategy">
<bean class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"/>
</property>
</bean>
<bean id="PropertiesRealm" class="com.ontoprise.security.realm.PropertiesRealm"> <
property name="resourcePath"><value>security.properties</value></property> </bean> </
beans> </source>
The l a s t few l i nes s peci fy the pa th to the text fi l e wi th the us er confi gura ti on: "s ecuri ty.properti es ". The next
s ecti on conta i ns a n exa mpl e for the content of a "s ecuri ty.properti es " fi l e.
</bean>
Note tha t a l s o the properti es rea l m confi gura ti on i s i ncl uded beca us e i t i s (currentl y) not pos s i bl e to s peci fy
pa s s words i n the s ecuri ty modul e rea l m. When the i nference s erver s ta rts up a nd you confi gured the s ecuri ty
modul e rea l m you s houl d s ee s omethi ng l i ke
INFO [CONFIG] Loading security ontology: file:/C:/OntoBroker/conf/$security.obl
147
OntoBroker 6.3 Rol e-Ba s ed Securi ty
:- module = '$security'.
:-prefix = "http://ontoprise.de/".
:-import = '$security-core'.
demo:User[hasRole->{m1all,m2read,foo}].
root:User[hasRole->allModules].
m3read:Role[hasReadPermission->m3].
m3write:Role[hasWritePermission->m3].
foo:Role[hasPermission->'foo:*'].
The thi rd l i ne s hows the requi red i mport. Here i s a s creens hot of the s chema of the s ecuri ty ontol ogy:
The fol l owi ng excerpt s hows the ObjectLogi c s ource of the s chema ontol ogy:
:- version("2.0").
:- encoding("Cp1252").
:- module = $'security-core'.
Module[].
Role[].
User[].
SpecialPermission::WildcardPermission.
// Instances --------------------------------------------
148
OntoBroker 6.3 Rol e-Ba s ed Securi ty
"*":Module.
allModules:Role.
allPermissions:Role.
"ob:command:apicommands":SpecialPermission.
"ob:command:busy":SpecialPermission.
"ob:command:clear":SpecialPermission.
"ob:command:commands":SpecialPermission.
...
To model your s ecuri ty ontol ogy you a l s o ha ve to open the s chema ontol ogy a nd the ontol ogi es for whi ch you
wa nt to s et the rol es a nd permi s s i ons . Here i s a s creens hot of OntoStudi o i n whi ch a s ecuri ty ontol ogy i s
edi ted:
The cha nges i n the s ecuri ty ontol ogy (rol es a nd permi s s i ons ) a re executed i mmedi a tel y when a permi s s i on/
rol e i s cha nged. Hence, i t i s pos s i bl e to try out new permi s s i ons i mmedi a tel y by executi ng queri es .
13.9 Mapping Groups and Roles from External Realms like LDAP
If us ers a nd groups a re ma na ged externa l l y, e.g. on a n LDAP s ys tem, you often wa nt to us e the exi s ti ng groups
a nd a tta ch permi s s i ons to them. Thi s ca n be done i n two s teps . Fi rs t of a l l , you wri te a rul e whi ch ma ps a n
externa l rol e of a nother rea l m to a rol e of the s ecuri ty modul e. Secondl y you defi ne permi s s i ons for the rol e.
Currentl y we onl y s upport Acti veDi rectory out-of-the-box, other LDAP s ys tems need s ome project effort (a few
hours to a few da ys ) to a da pt for the concrete LDAP s chema . Let's a s s ume your s ecuri ty confi gura ti on us es
Acti veDi rectory i n the fol l owi ng wa y:
149
OntoBroker 6.3 Rol e-Ba s ed Securi ty
</property>
</bean>
In thi s exa mpl e confi gura ti on for the us erPri nci pa l Na me the memberOf a ttri bute i s l ooked up a nd group
members hi ps i n the "groupRol es Ma p" a re ma pped to rol e na mes (here "rol e1" a nd "rol e2"). To us e thes e
Acti veDi rectory (AD) groups i n the rea l m Securi tyModul eRea l m you wri te rul es to ma p a group to one or more
rol es of the Securi tyModul eRea l m. In the fol l owi ng exa mpl e the AD rol e "rol e1" i s ma pped to the
Securi tyModul e rol es #m1a l l a nd #m3rea d. For thi s purpos e the bui l ti ns _ha s Rol e/1 a nd _currentUs er/1 a re
us ed. The bui l ti n _ha s Forei gnRol e i s true, i f the us er ha s a rol e wi th the gi ven na me i n a ny of the confi gured
rea l ms . The bui l ti n _currentUs er/1 returns the us er i n the gi ven query/s es s i on context.
- module = '$security'.
- prefix = "http://ontoprise.de/security#".
- import = '$security-core'.
... // similar as above
// if current user U has the role "Administrator" (role name of any configured realm)
// then the user should be assigned to the internal roles #m1all and #m3read ?- U U:
#User[hasRole->{m1all,m3read}] <- _currentUser(U) and _hasForeignRole(role1).
In OntoBroker the _ha s Rol e/1 Bui l ti n ha s been rena med to _ha s Forei gnRol e/1 a nd i t onl y a ppl i es to externa l
150
OntoBroker 6.3 Rol e-Ba s ed Securi ty
// ObjectLogic
- module = $security.
- importmodule '$security-core'.
... // similar as above
// if current user U has the role "Administrator" (role name of any configured
realm)
// then the user should be assigned to the internal roles #m1all and
#m3read ?U:User[hasRole->{m1all,m3read}] :- _currentUser(?U) and _hasForeignRole
(role1).
role.manager = ob:command:*,ob:collabserver:*
role.powerUser = ob:command:reload,ob:command:add,ob:command:del,ob:command:query
Thi s confi gura ti on ba s i ca l l y s a ys tha t Ja ne i s a l l owed to execute the fol l owi ng OntoBroker comma nds a nd
nothi ng el s e:
rel oa d
a dd
del
query
Joe i s a l l owed to execute a ny OntoBroker comma nds (i ncl udi ng "s hutdown"). The permi s s i on "ob:comma nd:*"
i s a s o-ca l l ed wi l dca rd permi s s i on.
Note:
If you a re worki ng wi th s ecuri ty a cces s a nd you a re us i ng the wi l dca rd permi s s i on, us ers who ha ve onl y
rea di ng permi s s i on ca n a l s o rea d the s ecuri ty ontol ogy a nd therefore know whi ch us er ha s whi ch
permi s s i on. If you do not wa nt thi s beha vi our, you mus t not us e the wi l dca rd permi s s i on. Ins tea d you ha ve
to ma nua l l y s et permi s s i on for ea ch modul e.
// if current user U has the role "role1" (role name of any configured realm)
// then the user should be assigned to the internal roles m1all and m3read
?U:User[hasRole->{m1all,m3read}] :- _currentUser(?U) and _hasForeignRole(role1).
151
OntoBroker 6.3 Rol e-Ba s ed Securi ty
13.13 Permissions
If Security.LoginRequired = on a nd Security:AccessControl = on, thes e permi s s i ons a uthori ze
s peci a l a cti ons a nd comma nds when the OntoBroker i s a cces s ed vi a Col l a bs erver, s ocket API or OntoBroker
web s ervi ce.
152
OntoBroker 6.3 Rol e-Ba s ed Securi ty
For col l a bs erver / remote API you now need the permi s s i on
"ob:col l a bs erver:a ddontol ogy" to crea te or i mport ontol ogi es .
ob:col l a bs erver:a ddontol ogy
Al terna ti vel y you a re a l l owed to perform thes e a cti ons i f you ha ve
wri te permi s s i ons on the ontol ogy to be crea ted or i mported.
ob:rea s oner:debug Permi s s i on hol der i s a l l owed to a cti va te tra ci ng on query executi on
Note:
The l oggi ng i s not fa i l s a fe: E.g. the l og-out i s typi ca l l y not l ogged when a ti meout occurs .
153
OntoBroker 6.3 Rol e-Ba s ed Securi ty
</list>
</property>
</bean>
In thi s exa mpl e defi ni ti ons for the cus tom permi s s i ons "depl oy" a nd "undepl oy" ha ve been a dded.
2. Us e thes e cus tom permi s s i ons i n rol es of the s ecuri ty ontol ogy($s ecuri ty.obl ).
Exa mpl e:
role1:Role[customPermission("deploy")->module1,customPermission("undeploy")->"*"].
In thi s exa mpl e a rol e "rol e1" i s defi ned wi th cus tom permi s s i on "depl oy" for modul e modul e1 a nd cus tom
permi s s i on "undepl oy" for a l l modul es .
3. a ) Us e _i s Cus tomPermi tted/2 to us e the cus tom permi s s i on i n your rul es or queri es :
Exa mpl e:
?- _isCustomPermitted(module1, "deploy").
Thi s query woul d return true i f us er ha s a bove defi ned rol e1
3. b) Us e cus tom permi s s i ons progra mma ti ca l l y wi th the OntoBroker API.
import com.ontoprise.security.CustomPermission;
SessionFacade sf = ....;
Term module = ...;
CustomPermission custperm = new CustomPermission(module, "deploy");
boolean permitted = SessionFacadeSecurityHelper.isPermitted(sf, custperm);
Authenti ca ti on
Authenti ca ti on i s the a ct of confi rmi ng the i denti ty of a s ubject (a us er). The mos t common method of
confi rmi ng a n i denti ty i s wi th a us erna me/pa s s word combi na ti on (i t i s checked i f the pa s s word i s correct).
Authori za ti on
Thi s i s the a ct of confi rmi ng i f a s ubject ha s the ri ght permi s s i ons to execute s ome a cti on. For exa mpl e, a
check i s ma de tha t us er "Joe" ha s the permi s s i on to execute the "s hutdown" comma nd.
Rea l m
A rea l m i s a res ource whi ch a l l ows a cces s to the s ecuri ty components of a n a ppl i ca ti on (us ers , pa s s words ,
rol es , permi s s i ons ). So rea l ms a re res pons i bl e for both a uthenti ca ti on a nd a uthori za ti on.
Subject
Rol e
A us er ca n ha ve mul ti pl e rol es . For exa mpl e, a us er ca n ha ve the rol e "devel oper", but he ca n a l s o be
res pons i bl e for the a dmi ni s tra ti on (rol e: a dmi ni s tra tor) or for the s a l es (rol e: s a l es ). A rol e i s ba s i ca l l y a
col l ecti on of permi s s i ons .
Pri nci pi a l
Pri nci pi a l s a re the i denti fyi ng a ttri butes of a s ubject (na me, i d, ...).
Credi denti a l s
154
OntoBroker 6.3 Rol e-Ba s ed Securi ty
Permi s s i on
155
OntoBroker 6.3 Confi guri ng OntoBroker
14 Configuring OntoBroker
OntoBroker ha s s evera l s wi tches to i nfl uence i ts runti me beha vi our. Al l s wi tches ca n be s et i n the
confi gura ti on fi l e <OntoConfi g.prp> whi ch res i des i n the s ta rti ng di rectory of the s erver (us ua l l y the
i ns ta l l a ti on ba s e di rectory of the s erver). The s wi tches ca n be grouped i nto ma i nl y three ca tegori es . Fi rs t the
us er ca n ena bl e the us e of the i nterna l da ta ba s e. A s econd group ena bl es the us er to modi fy the
performa nce beha vi our of the s erver. Thes e s wi tches depend on the us e of the s erver a nd ha ve to be us ed
ca reful l y. The thi rd group a l l ows the eva l ua ti on mode a nd fea tures to be i nfl uenced. Thi s cha pter gi ves a n
overvi ew of the di fferent s wi tches , wel l a s a bri ef des cri pti on.
156
OntoBroker 6.3 Confi guri ng OntoBroker
157
OntoBroker 6.3 Confi guri ng OntoBroker
158
OntoBroker 6.3 Confi guri ng OntoBroker
159
OntoBroker 6.3 Confi guri ng OntoBroker
Command Function
160
OntoBroker 6.3 Confi guri ng OntoBroker
uncha nged. Thi s conti nues unti l the wa nted number of genera ti ons ha s been ca l cul a ted.
Limits
As the conti nuum of a l l pos s i bl e reorderi ng i s very bi g, you wi l l need ma ny i ndi vi dua l s to tes t. For compl ex
rul e s cena ri os s evera l thous a nd i ndi vi dua l s s houl d be crea ted, s o tha t i t ta kes a l ot of ti me to opti mi ze a
l ong-runni ng query. Another probl em ma y be the memory dema nd of the query eva l ua ti on. Some
permuta ti ons wi l l need much more memory tha n the a vera ge. If you a l rea dy opera te on the l i mi ts OntoBroker
ca n ha ndl e wi th the a va i l a bl e ma i n memory, you mi ght encounter out of memory" errors when us i ng geneti c
opti mi zer.
NOTE: If you opti mi ze a s peci fi c query wi th the geneti c opti mi zer a nd you cha nge the rul es or the fa cts then
you wi l l need to execute the geneti c opti mi zer a ga i n. If you onl y cha nge the cons ta nts or the order of l i tera l s
i n a rul e you do not need to opti mi ze the query a ga i n.
Usage
Command Description
opt_genetic The return va l ue i s a s tri ng. The s ta tus of the l a s t compl ete genera ti on wi l l be
status returned.
At l ea s t one genera ti on ha s to be eva l ua ted before va l i d res ul ts ca n be del i vered.
OntoBroker Return Va l ues : The return va l ue i s a "s tri ng" wi thout l i ne s epa ra tors .
Us e | a s s epa ra ti on cha ra cter.
opt_genetic kill Stops a runni ng opti mi za ti on. It ma y ta ke a s hort ti me, you ca n us e the -
i s opti mi zi ng comma nd to s ee when i t i s done. The ti meout wi ndow ha s to fi t i nto
the ti meout of the s ocket connecti on, s o tha t i t ma y be too s ma l l for s ome ca s es .
Options Description
14.3.2 EliminateDuplicates
Thi s s wi tch ca n be s et i n OntoConfi g.prp vi a :
EliminateDuplicates = <on|off>
Duri ng the eva l ua ti on proces s of a query (s ub-) res ul ts ma y be i nferred i n di fferent wa ys (e.g. a tupl e ca n be
s tored i n s ome fa cts ta bl e or i t ca n be i nferred by a rul e). Dupl i ca tes ca n a l s o occur a s the res ul t of joi n
opera ti ons . If El i mi na teDupl i ca tes =on (thi s i s the defa ul t) then a l l dupl i ca tes a re removed from the res ul t
tupl es . Removi ng dupl i ca tes mi ght be a cos tl y opera ti on a nd there a re s ome us e ca s es where you s i mpl y do
161
OntoBroker 6.3 Confi guri ng OntoBroker
not ca re a bout dupl i ca tes . In thi s ca s e i t i s recommended to s et El i mi na teDupl i ca tes =off a s the res ul t i s
returned fa s ter.
14.3.3 ConceptNamesGround
Thi s s wi tch ca n be s et i n OntoConfi g.prp vi a :
ConceptNamesGround = <on|off>
Thi s s wi tch ca n i mprove performa nce s i gni fi ca ntl y i n mos t ca s es , but i n s ome ca s es i t ca n a l s o deteri ora te
the performa nce.
Norma l l y OntoBroker ha s one ta bl e for a l l concept-i ns ta nce pa i rs ca l l ed <$a s s ertedi s a >. Thi s mea ns i f you
ha ve the fol l owi ng i ns ta nces :
Tom:Cat.
Garfield:Cat.
Jerry:Mouse.
SpeedyGonzales:Mouse.
$assertedisa_Mouse
--------------
Jerry
SpeedyGonzales
When us i ng ConceptNamesGround=with the cons equence tha t no rul es a re no l onger a l l owed whi ch ha ve
nonground a rguments a t concept pos i ti ons i n rul e hea ds .
The rea s on i s tha t OntoBroker woul d ha ve to crea te a new ta bl e for ea ch va l ue of Y whi ch i s not yet i n the
da ta ba s e. To keep i t s i mpl e: If you ha ve s uch rul es i n your ontol ogy you ca nnot us e the ConceptNa mes Ground
s wi tch (OntoBroker wi l l detect thi s a nd wi l l refus e to s ta rt). Why woul d you wa nt to us e the
ConceptNa mes Ground s wi tch? Wel l , there a re two rea s ons . The fi rs t one i s the i mproved performa nce. It i s
s i mpl y chea per to query the ta bl es i f you ha ve fewer res tri cti ons . E.g. i f you wa nt to retri eve a l l ca ts from
OntoBroker then you pos e the query:
?- ?X:"Cat".
When ConceptNa mes Ground i s off, then OntoBroker mus t s ca n the ta bl e "$a s s ertedi s a " a nd check for ea ch
el ement i f the s econd pa ra meter i s "Ca t". (Of cours e OntoBroker us es i ndi ces for a cces s i ng ta bl es but the
genera l i dea i s tha t the queri es a re chea per i f the ta bl es a re s ma l l er.) If ConceptNa mes Ground i s us ed
OntoBroker onl y needs to query a s i ngl e ta bl e to get the res ul ts . So thi s i s a typi ca l exa mpl e of a query whi ch
ca n be eva l ua ted fa s ter i f ConceptNa mes Ground i s us ed. The more concepts you ha ve the chea per a query for
i ns ta nces becomes . However, there a re s ome types of queri es whi ch a re s l ower when ConceptNa mes Ground
i s us ed. If you do not us e a concept res tri cti on for your queri es then the performa nce degra des . Cons i der the
fol l owi ng query:
?- ?X:?Y.
Thi s ki nd of query i s s l ower when ConceptNamesGround i s us ed beca us e i n thi s ca s e OntoBroker mus t query
a l l "$a s s ertedi s a " ta bl es ($a s s ertedi s a _Ca t, $a s s ertedi s a _Mous e, ...). When ConceptNamesGround i s turned
off then OntoBroker mus t onl y query a s i ngl e ta bl e. So ba s i ca l l y you ha ve to deci de between good
performa nce for queri es wi th res tri cti ons or good performa nce for queri es wi thout res tri cti ons . The s econd
rea s on for choos i ng ConceptNamesGround=on i s tha t i t i s much ea s i er to dea l wi th nega ti ons i n rul es . If you
162
OntoBroker 6.3 Confi guri ng OntoBroker
ever encounter a "Stra ti fi ca ti onExcepti on" then s wi tchi ng to ConceptNa mes Ground=on mi ght hel p.
14.3.4 AttributeNamesGround
Thi s s wi tch ca n be s et i n OntoConfi g.prp vi a :
AttributeNamesGround = <on|off>
Thi s s wi tch works exa ctl y i n the s a me wa y a s "ConceptNa mes Ground", but now a ttri bute na mes a re ground
a nd not concept na mes . The a ttri butes a re s tored i n the ta bl e <$a tt_>. If you ha ve s ta tements l i ke
Cat[likes=>Mouse].
Mouse[isAfraidOf=>Mouse].
then we ha ve the ta bl e "$a tt_" for Attri buteNa mes Ground=off a nd "$a tt_l i kes " a nd "$a tt_i s Afra i dOf" for
Attri buteNa mes Ground=on.
The performa nce cha ra cteri s ti cs rega rdi ng queri es wi th res tri cti ons on a ttri bute na mes a nd rega rdi ng queri es
wi thout res tri cti ons on a ttri bute na mes a re ba s i ca l l y the s a me a s wi th "ConceptNa mes Ground". If
<Attri buteNa mes Ground> i s us ed there ma y not be a rul e wi th a hea d conta i ni ng a va ri a bl e for the rel a ti on
na me a s thes e ca nnot be rei nterpreted duri ng compi l e ti me. Note tha t thi s opti on i s not s upported for
OntoStudi o.
14.5.1 Configuration
To us e H2 a s s tora ge i n OntoBroker, you ha ve to s et a t l ea s t two va l ues i n your OntoConfi g.prp:
Storage = H2
H2.URL = jdbc:h2:file:<path>/<dbname>
The pa th ca n be omi tted or ca n be rel a ti ve to the worki ng di rectory. As a fol der s epa ra tor you s houl d us e the
norma l s l a s h / i ns tea d of the ba cks l a s h \.
163
OntoBroker 6.3 Confi guri ng OntoBroker
1. Exa mpl e:
H2.URL = jdbc:h2:file:data/edb
Thi s wi l l crea te the da ta ba s e fi l es i n the s ubdi rectory da ta (rel a ti ve to the worki ng di rectory) a nd a l l
da ta ba s e fi l es wi l l s ta rt wi th "edb".
2. Exa mpl e:
H2.URL = jdbc:h2:file:d:/home/storage/mydb
Thi s wi l l crea te the s tora ge fi l es i n the di rectory d:\home\s tora ge a nd a l l s tora ge fi l es wi l l s ta rt wi th "mydb".
H2 ma y crea te, enl a rge a nd del ete fi l es a l l the ti me, even i f you a re us i ng OntoBroker wi th rea di ng a cces s
onl y. Therefore OntoBroker wi th H2 needs crea te a nd wri te permi s s i ons on the di rectory where the s tora ge
fi l es a re l oca ted.
test.h2.db Da ta ba s e fi l e. 1 per da ta ba s e
Conta i ns the tra ns a cti on l og, i ndexes , a nd da ta for a l l
ta bl es .
Forma t: <da ta ba s e>.h2.db
Furthermore, you ma y cha nge the fol l owi ng confi gura ti on va l ues i n OntoConfi g.prp:
H2.TermCacheSize = 100000
Thes e pa ra meters s et the ca che s i ze for the tra ns l a ti on between term i ds us ed i n the da ta ba s e a nd term
objects i n OntoBroker. There a re two ca ches , one us ed ma i nl y for the fi rs t a rgument of predi ca tes a nd one for
a l l other a rguments . If you ha ve l ots of ma i n memory, you ma y i ncrea s e thes e ca che s i zes .
164
OntoBroker 6.3 Confi guri ng OntoBroker
14.5.4 Backup
If OntoBroker i s not runni ng, you ca n ba ckup the H2 da ta ba s e s i mpl y by copyi ng a l l of the da ta ba s e fi l es . In
fa ct i t i s even enough to ba ckup the <dbna me>.da ta .db fi l e. However, i n thi s ca s e H2 wi l l regenera te the
da ta ba s e i ndex fi l e <dbna me>.i ndex.db conta i ni ng a l l i ndi ces duri ng the next s ta rtup of OntoBroker.
Recrea ti ng i ndi ces ma y ta ke s ome ti me, dependi ng on the da ta ba s e s i ze a nd computi ng power of your
computer (typi ca l l y a few mi nutes per GB).
Note:
The comma nd "h2ba ckup" i s onl y a va i l a bl e i f OntoBroker i s runni ng wi th H2 a s s tora ge.
Us a ge:
h2backup <output-name>
The s i ngl e a rgument s peci fi es the ta rget fi l ena me of the da ta ba s e copy.
Exa mpl e:
h2backup d:\\backup\\mybackup.data.db
Thi s ba ckups the da ta ba s e fi l e to "d:\\ba ckup\\myba ckup.da ta .db."
CAUTION:
All files like "d:\\backup\\mybackup.*" are deleted during the copy action to prevent the possible mixing of
old and new temporary database files.
165
OntoBroker 6.3 Confi guri ng OntoBroker
webcons ol e", OntoBroker l i s tens to a n a ddi ti ona l port for provi di ng the web s ervi ce API. Thi s port i s 8267 by
defa ul t a nd ca n be cha nged us i ng the s wi tch Ws HttpPort = <port>.
WsHttpPort= 8267
Thi s s wi tch ca n be overrul ed by the comma ndl i ne opti on "-ws port <port>".
166
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
Profiling
If you execute a query a nd you wa nt to know where OntoBroker s pends mos t of the query ti me then us e the
query opti on "profi l e". The cha pter "Query Opti on profi l e" 67 gi ves deta i l ed i nforma ti on a bout the profi l i ng
fea ture. Thi s i s us ua l l y the bes t s ta rti ng poi nt for unders ta ndi ng the performa nce cha ra cteri s ti cs of queri es .
15.1.1.1 BottomUp
BottomUp i s the s i mpl es t eva l ua ti on s tra tegy. In ma ny ca s es thi s method provi des the bes t performa nce of
a l l of the eva l ua ti on methods . Its bi gges t di s a dva nta ge i s tha t no va ri a bl e bi ndi ngs a re propa ga ted top-
down.
15.1.1.2 MagicSet
The Ma gi cSet method (we us e the s o-ca l l ed "genera l i zed s uppl ementa ry ma gi c s ets ") tri es to i mprove the
performa nce of the BottomUp eva l ua ti on by propa ga ti ng bi ndi ngs top-down. For tha t purpos e a ddi ti ona l
rul es a re genera ted whi ch s i mul a te the top-down propa ga ti on. For exa mpl e, i f you ha ve the rul es
RULE r1: p(?X,?Y) :- q(?X,?Y) AND r(?X,?Y).
QUERY q1: ?- p(a,Y).m_p_bf(a).
RULE r1: pbf(?X,?Y) :- m_pbf(?X) AND q(?X,?Y) AND r(?X,?Y).
QUERY q1: ?- p_bf(a,Y).
Thi s s tra nge-l ooki ng progra m opti mi zes the ori gi na l progra m by propa ga ti ng the "a " to then the Ma gi cSet
tra ns forma ti on tra ns forms thi s rul e i nto s omethi ng l i ke the rul e "r1". Thi s mea ns rul e "r1" wi l l onl y crea te
167
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
tupl es whi ch a l rea dy ha ve a n "a " a t the fi rs t pos i ti on. Thi s progra m i s then eva l ua ted wi th a bottom up
eva l ua tor. So Ma gi cSet a ddi ti ona l l y requi res you to choos e a n a ppropri a te bottom up eva l ua ti on method (s ee
bel ow). In order to s ta rt OntoBroker wi th thi s eva l ua ti on method s et
EvaluationMethod=MagicSet
i n OntoConfi g.prp
15.1.1.3 DisjunctiveMagicSet
Thi s i s a nother va ri a nt of the Ma gi cSet a l gori thm. Thi s a l gori thm i mpl ements the s a me i dea a s the ori gi na l
Ma gi cSet a l gori thm, but genera tes l es s rul es . Aga i n the rewri tten progra m i s then eva l ua ted wi th a bottom up
eva l ua tor. So Di s juncti veMa gi cSet a ddi ti ona l l y you requi res to choos e a n a ppropri a te bottom up eva l ua ti on
method (s ee bel ow). In order to s ta rt OntoBroker wi th thi s eva l ua ti on method s et
EvaluationMethod=DisjunctiveMagicSet
15.1.1.4 DynamicFiltering2
Thi s i s a more memory-effi ci ent a nd fa s t vers i on of the proven Dyna mi cFi l teri ng eva l ua ti on method. In mos t
ca s es you s houl d us e Dyna mi cFi l teri ng2 i ns tea d of Dyna mi cFi l teri ng. Thi s eva l ua ti on method ba s i ca l l y
i mpl ements the i dea s of the Ma gi cSet a l gori thm di rectl y i n the i nference kernel wi thout genera ti ng
a ddi ti ona l rul es . Thi s ha s two i mporta nt a dva nta ges :
Les s rul es ha ve to be eva l ua ted
The eva l ua ti on opera tes on the ori gi na l rul es whi ch ma kes i t ea s i er to unders ta nd the eva l ua ti on
Currentl y Dyna mi cFi l teri ng2 i s the bes t choi ce for pers i s tent s tora ge s ys tems . In order to s ta rt OntoBroker wi th
thi s eva l ua ti on method s et
EvaluationMethod=DynamicFiltering2
i n OntoConfig.prp.
15.1.1.5 Choose
Thi s eva l ua ti on method checks the progra m cha ra cteri s ti cs a nd deci des whi ch eva l ua ti on method (BottomUp,
Di s juncti veMa gi cSet or Dyna mi cFi l teri ng) s houl d be us ed for a s peci fi c query. Some of the cha ra cteri s ti cs
whi ch wi l l be checked a re:
Is the progra m bottomup eva l ua bl e?
Does the progra m conta i n functi on s ymbol s ?
Does the progra m conta i n s tra ti fi ed or wel l founded nega ti ons ?
Do we need to crea te expl a na ti ons ?
Do the rul es ha ve di s juncti ons i n the hea d?
How ma ny rul es a re i n the progra m?
How s el ecti ve i s the query?
Typi ca l l y "choos e" wi l l s el ect a n a ppropri a te eva l ua ti on method, s o s etti ng. You ha ve to be a wa re tha t
“choos e” us es heuri s ti cs to deci de on a n eva l ua ti on method. Heuri s ti cs ca n fa i l . So i t ma y be the ca s e tha t
“choos e” does not fi nd the opti ma l eva l ua ti on s tra tegy.
EvaluationMethod=choose
168
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
Storage = RAM.TS
If RAM.TS i s us ed, the defa ul t bottomup eva l ua tor wi l l be BU3 (BU3 onl y works wi th RAM.TS). RAM.TS i s more
memory effi ci ent tha n RAM.AVL.Pa cked. In thi s ca s e BottomUp3 mi ght be the bes t choi ce for you.
Note:
You ca n run the eva l ua ti on methods wi th a l l s tora ge s ys tems .
169
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
15.2 Optimizers
OntoBroker s upports mul ti pl e opti mi zers (mos t of them jus t rewri te a s et of rul es i nto a n opti mi zed s et of
rul es ). However, s ometi mes opti mi zers jus t wa s te ti me a nd s pa ce. E.g. i f you a re not a cces s i ng a da ta ba s e
then you do not need to us e the da ta ba s e opti mi zers . Si nce OntoBroker 5.2 i t i s pos s i bl e to a cti va te or
dea cti ve thes e opti mi zers . Fi nd a l l opti mi zer s etti ngs here 270 .
170
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
Unfortuna tel y the i nterpl a y of di fferent rul es together wi th the StrongUnfol der s ometi mes l ea ds to a n
expl os i on of rul es . In thes e ca s es genera ti on of the res ul ti ng rul es a nd the eva l ua ti on of thes e rul es ma y
ta ke a l ot of ti me. It i s ha rdl y predi cta bl e when thi s effect occurs . Therefore the StrongUnfol der i s s wi tched
off by defa ul t, but i t i s s trongl y recommended to try i t es peci a l l y i n i ntegra ti on s cena ri os .
Simple Unfolder
Gi ven the fol l owi ng rul e a nd query:
p(?X) :- q(?X,?Y) AND r(?Y).
?- p(?Z) AND t(?Z).
Then unfol di ng s ubs ti tutes the l i tera l p(Z) i n the query by the body of the rul e a nd del etes the rul e:
?- q(?Z,?Y) AND r(?Y) AND t(?Z).
The s wi tch
Rewriter.SimpleUnfolder = on
i s per defa ul t s et to "on". In mos t ca s es thi s opti on s houl d never be s et to "off".
171
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
Note:
Beca us e of performa nce i s s ues , do not us e the s chema opti mi zer a nd the fra me opti mi zer a t the s a me
ti me. When ontol ogy i mports a re us ed then we recommend us i ng the MergeImports OntoConfi g opti on.
MergeImports ca nnot be us ed i n a n OntoStudi o context.
15.2.10 FrameOptimizer
In ObjectLogi c you ma y ha ve s omethi ng l i ke:
X:Person[hasName->Y].
thi s wi l l s pl i t i nto
X:Person and X[hasName->Y].
´Thi s ha s es s enti a l di s a dva nta ges duri ng the eva l ua ti on! The Fra meOpti mi zer merges thes e fa cts i f pos s i bl e:
att(X,Person,hasName,Y).
Thi s mea ns enormous ti me-s a vi ngs i n a n i ntegra ti on s cena ri o.
Exa mpl e
172
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
… :- ?X:Person[hasAge->?Y] …
opti mi zed:
… :- att(Person,hasAge,Y) …
Note:
Beca us e of performa nce i s s ues do not us e the s chema opti mi zer a nd the fra me opti mi zer a t the s a me ti me.
15.2.12 MergeImports
If the MergeImports pa ra meter i s s et to "on" i n the OntoConfi g.prp, i mported ontol ogi es a re di rectl y merged
i nto the i mporti ng root ontol ogy. Thi s mea ns tha t the i mported ontol ogi es a re not a va i l a bl e a s s epa ra te
ontol ogi es a s i n OntoStudi o.
Exa mpl e
To a cti va te the MergeImports s wi tch, i n the OntoConfi g.prp s et
MergeImports = on
As s ume tha t you ha ve three ontol ogi es A,B, a nd C. A i mports B a nd B i mports C. Then, a fter l oa di ng you ha ve
onl y one ontol ogy A' (cons i s ti ng of rul es a nd fa cts from A,B, a nd C).
Note 1:
The fl a g i nfl uences onl y the l oa di ng proces s on OntoBroker s ta rt (or rel oa d comma nd).
Note 2:
The MergeImports fl a g ca nnot be us ed together wi th project fi l es .
However, thi s s equence i s not the opti ma l joi n s equence a s ma ny tupl es tha t a re crea ted e.g. by the "P:
Pl a yer" l i tera l a re l a ter di s ca rded i n joi n opera ti ons . So the fol l owi ng s equence s trongl y reduces thi s effect:
QUERY q1: ?- ?P["inTournament"->?WM].
RULE r1: "P"["inTournament"->"WM"].
173
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
<-
WM:Tournament AND // 25 tuples
WM[match -> M] AND // 30 tuples
M[team -> T] AND // 2 tuples
T[lineup -> P] AND // 11 tuples
P:Player. // 1000 tuples
Thi s i s exa ctl y the ca s e where fea tures l i ke the cos t model or the geneti c opti mi zer come i nto pl a y. Both
fea tures us e di fferent s tra tegi es to opti mi ze the joi n s equence, but both a re a bl e to i mprove performa nce
s i gni fi ca ntl y.
Limits
As the conti nuum of a l l pos s i bl e reorderi ng i s very bi g, you wi l l need ma ny i ndi vi dua l s to tes t. For compl ex
rul e s cena ri os s evera l thous a nd i ndi vi dua l s s houl d be crea ted, s o tha t i t ta kes a l ot of ti me to opti mi ze a
l ong-runni ng query. Another probl em ma y be the memory dema nd of the query eva l ua ti on. Some
permuta ti ons wi l l need much more memory tha n the a vera ge. If you a l rea dy opera te on the l i mi ts OntoBroker
ca n ha ndl e wi th the a va i l a bl e ma i n memory, you mi ght encounter out of memory" errors when us i ng the
geneti c opti mi zer.
Note:
If you opti mi ze a s peci fi c query wi th the geneti c opti mi zer a nd you cha nge the rul es or the fa cts then you
wi l l need to execute the geneti c opti mi zer a ga i n. If you onl y cha nge the cons ta nts or the order of l i tera l s i n
a rul e you do not need to opti mi ze the query a ga i n.
Usage
opt_genetic <queryID>
Comma nds to s end a n opti mi zed query to OntoBroker
174
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
Command Description
opt_genetic The return va l ue i s a s tri ng. The s ta tus of the l a s t compl ete genera ti on wi l l be
status returned.
At l ea s t one genera ti on ha s to be eva l ua ted before va l i d res ul ts ca n be del i vered.
OntoBroker Return Va l ues : The return va l ue i s a "s tri ng" wi thout l i ne s epa ra tors . Us e
| a s s epa ra ti on cha ra cter.
opt_genetic kill Stops a runni ng opti mi za ti on. It ma y ta ke a s hort ti me, you ca n us e the -i s opti mi zi ng
comma nd to s ee when i t i s done. The ti meout wi ndow ha s to fi t i nto the ti meout of
the s ocket connecti on, s o i t ma y be to s ma l l for s ome ca s es .
Option Description
Usage
175
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
Option Description
Limitations
Rul e bodi es s houl d not ha ve ma ny l i tera l s ! If you ha ve e.g. 10 rul e bodi es you ha ve to dea l wi th 10
permuta ti ons . In thi s ca s e i t woul d be better to dea cti va te the unfol di ng.
15.3.3 BodyOrdering
BodyOrderi ng i s the s equence of F-a toms executed i n a rul e or query. E.g. when you ha ve
?- ?X:Person AND ?X[hasName->?Y] AND ?X[worksAt->?Z].
then pos s i bl e body orderi ngs a re
When choos i ng "BodyOrderi ng = a uto" then OntoBroker wi l l try to opti mi ze the s equence of F-a toms i n the
query. When choos i ng "BodyOrderi ng = off" then the s equence of F-a toms wi l l s ta y i t i t i s :
?- ?X:Person AND ?X[hasName->?Y] AND ?X[worksAt->?Z].
Note:
Thi s mi ght l ea d to s i tua ti ons where the whol e progra m i s not eva l ua bl e a nymore or where the query
returns wrong res ul ts .
176
OntoBroker 6.3 OntoBroker Performa nce Tuni ng
The fol l owi ng OntoConfi g opti ons a l l ow externa l da ta ba s e a cces s to be tra ced:
#Trace.ExternalDatabase = off
#Trace.ExternalDatabase.SQL = off
177
OntoBroker 6.3 Rul e Ma na gement
16 Rule Management
If you wa nt a n ea s y wa y to
Fi nd rul es by modul e a nd rul e i denti fi er
Retri eve rul e by rul e i denti fi er
Sea rch for rul es conta i ni ng a ObjectLogi c term (concept/i ns ta nce) i n the hea d or body
Sea rch for rul es conta i ni ng s ome text
Add a nd remove rul es
then you ca n us e the rul e ma na gement fea tures of OntoBroker. Expl a na ti ons a nd expl a na ti on rul es a re
des cri bed i n the Explanations cha pter.
Exa mpl e:
"Add facts q(1,a) and q(2,b) to m odule m 1, and exchange rule r1 w ith follow ing rule: @ {r1} p(? X) :- q(? X,? )."
:- module m1.
insert {q(1,a),q(2,b)}
delete rule r1.
insert rule {@{r1} p(?X) :- q(?X,?).}
178
OntoBroker 6.3 Expl a na ti ons
17 Explanations
A fea ture of OntoBroker i s to expl a i n the rea s on why a query returns s peci fi c res ul ts . Thi s cha pter s hows how
to ena bl e the expl a na ti on fea ture i n OntoBroker a nd gi ve a n exa mpl e of how to formul a te s o-ca l l ed
expl a na ti on rul es .
Basics
Retri evi ng expl a na ti ons i s done i n two s teps
Fi rs t execute the query wi th the "expl a i n" query opti on
Then execute a nother query to retri eve the expl a na ti ons for the fi rs t query
If a n expl a na ti on for a genera ted a ns wer i s reques ted, i t i s neces s a ry tha t ea ch rel eva nt rul e of the ontol ogy
i s a ccompa ni ed by a n expl a na ti on rul e. Thes e rul es conta i n text bl ocks to expl a i n the mea ni ng i n common
l a ngua ge, i ncl udi ng pl a ce hol ders for the concrete i ns ta nti a ti ons of the rul e va ri a bl es .
Exa mpl e
We ha ve a ObjectLogi c ontol ogy des cri bi ng peopl e a nd the compa ny they work i n:
// Concept hierarchy ------------------------------------
Company[].
Employee[].
// Schema -----------------------------------------------
Employee[colleague {0:*} *=> Employee].
Employee[company {0:*} *=> Company].
// Instances --------------------------------------------
christian:Employee.
eva:Employee.
ibm:Company.
ontoprise:Company.
patrick:Employee.
roman:Employee.
saartje:Employee.
// Properties -------------------------------------------
christian[company->ibm].
eva[company->ontoprise].
patrick[company->ibm].
roman[company->ontoprise].
saartje[company->ontoprise].
Addi ti ona l l y we ha ve a rul e tha t s ta tes tha t i f two empl oyees work a t the s a me compa ny they a re col l ea gues :
@{ruleColleague}
?A[colleague->?D] :- ?A:Employee AND ?A[company->?F] AND ?D:Employee AND ?D[company-
>?F] AND ?F:Company AND NOT _unify(?A,?D).
You ca n pos e the fol l owi ng query to a s k for peopl e a nd thei r col l ea gues :
@{queryColleague, options[outorder(?Employee2,?Employee1)]}
?- ?Employee2:Employee and ?Employee1:Employee[colleague->?Employee2].
179
OntoBroker 6.3 Expl a na ti ons
Now you mi ght wa nt to expl a i n why two peopl e (repres ented by the va ri a bl es denoted by $A$ a nd $D$) a re
col l ea gues .
$A$ and $D$ are colleagues because they are both employees of the company $F$
Note tha t OntoBroker a l l ows expl a na ti on rul es to be genera ted a utoma ti ca l l y, s o you do not ha ve to wri te
thi s rul e ma nua l l y (s ee bel ow for deta i l s ). Queryi ng for a l l empl oyees a nd thei r col l ea gues woul d be done i n
the fol l owi ng wa y:
?- ?Employee2:Employee and ?Employee1:Employee[colleague->?Employee2].
If res ul t expl a na ti ons a re requi red, thi s i s done us i ng a n a ddi ti ona l a nnota ti on:
@{options[explain]} ?- ?Employee2:Employee and ?Employee1:Employee[colleague->?
Employee2].
Thi s wi l l bri ng the s a me res ul ts a s before but wi l l i nterna l l y crea te a new modul e for the query s es s i on. The
modul e conta i ns the i nforma ti on needed to crea te the expl a na ti ons . They ca n be queri ed i n the fol l owi ng
wa y:
?- _explain(?QK, ?RID, ?S).
Where:
?QK: i s a va ri a bl e repres enti ng the query s es s i on
?RID: i s the res ul t i d
180
OntoBroker 6.3 Expl a na ti ons
Generated template
'$aPerson1$ hatKind $aPerson3$
BECAUSE
$aPerson1$ is a Person AND
$aPerson2$ is a Person AND
$aPerson3$ is a Person AND
$aPerson1$ ns_(#,hasChildWith($aPerson2$)) $aPerson3$'
Typi ca l l y you wi l l edi t thi s templ a te to a bs tra ct from the rul e deta i l s a nd focus on the s ta tement of the rul e.
Wi th the fi na l templ a te you ca n then us e the bui l t-i n _genera teExpl a na ti onRul eText/4 to genera te the rul e
text of the expl a na ti on rul e:
?- _generateExplanationRuleText("m1","r1","""$aPerson1$ hatKind $aPerson3$
BECAUSE
$aPerson1$ is a Person AND
181
OntoBroker 6.3 Expl a na ti ons
Note:
Querykey: As the OntoBroker runs a s a s erver there ma y be s evera l queri es a t a ti me. To be a bl e to
i denti fy the reques ted expl a na ti on, ea ch query i s uni quel y i denti fi ed by a key. Thi s key a l l ows the
expl a na ti on for the query to be a cces s ed. The querykey i s a cces s i bl e vi a the API of the QueryCl i ent
(pl ea s e s ee the Ja va Docs for further i nforma ti ons ).
Caching: When the expl a na ti on fea ture i s us ed, ea ch executed query genera tes expl a na ti on i nforma ti on
s tored a t the s erver. To prevent the s ys tem runni ng out of memory i t i s neces s a ry to remove the genera ted
expl a na ti on us i ng the removeExpl a na ti on comma nd. Thi s comma nd ta kes the querykey a s a n a rgument
a nd wi l l tel l the s erver to cl ea n up a l l i nforma ti on rel a ted to the expl a na ti on of thi s concrete query.
Explanations: OntoStudi o provi des a n gra phi ca l us er i nterfa ce for dea l i ng wi th expl a na ti ons .
182
OntoBroker 6.3 Fi l e Encodi ngs a nd Uni code
183
OntoBroker 6.3 OntoBroker Server
19 OntoBroker Server
19.1 Launching OntoBroker
OntoBroker32.exe a nd OntoBroker64.exe s ta rt wi th a 32bi t a nd 64 bi t Ja va VM res pecti vel y. In contra s t to
OntoBroker 5.3, thes e l a unchers do not l a unch a s epa ra te Ja va proces s a nd ca n therefore be us ed for
l a unchi ng OntoBroker a s a s ervi ce (thi s requi res thi rd pa rty tool s ).
Sta rti ng wi th OntoBroker 6.0, OntoBroker i s embedded i n Equi nox, a n OSGi fra mework. To keep the
confi gura ti on of OntoBroker s i mpl e, the l a unchi ng i nvol ves mul ti pl e s teps . Before the Equi nox fra mework
i ts el f i s s ta rted a nd the OSGi bundl es a re a cti va ted, s evera l s ys tem properti es a re s et ei ther from pa ra meters
of the OntoConfi g.prp, or they a re ca l cul a ted. In deta i l the fol l owi ng ta kes pl a ce a t thi s s ta ge:
Pa ra meters from OntoConfi g.prp a re tra ns l a ted to Sys tem properti es for the Equi nox fra mework
HttpPort => org.ecl i ps e.equi nox.http.jetty.http.port
Extens i ons .Di rectory => fel i x.fi l ei ns ta l l .di r
l og4j.confi gura ti on => l og4j.confi gura ti on
WorkerNa me => com.ontopri s e.ontobroker.jetty.cus tomi zer.workerna me
AJP => com.ontopri s e.ontobroker.jetty.cus tomi zer.a jp
AJP.Port => com.ontopri s e.ontobroker.jetty.cus tomi zer.a jp.port
l a uncher.* => *
(thi s mea ns a l l confi g pa ra meters i n OntoConfi g s ta rti ng wi th the prefi x "l a uncher." a re copi ed to the
s ys tem properti es a fter removi ng the prefi x)
Addi ti ona l l y, the fol l owi ng defa ul t s ys tem properti es a re a dded i f they a re not defi ned a s "l a uncher.*"
pa ra meter i n the OntoConfi g.prp:
os gi .requi redJa va Vers i on=1.6
os gi .noShutdown=true
ecl i ps e.i gnoreApp=true
os gi .i ns ta l l .a rea =$ONTOBROKER_HOME/pl ugi ns
184
OntoBroker 6.3 OntoBroker Server
185
OntoBroker 6.3 OntoBroker Server
HttpPort Port for Web s erver us ed Default: 8287 Thi s repl a ces the
for the col l a bora ti on pa ra meter WsHttpPort
s erver, remote API, web HttpPort = 8287
a nd the comma nd l i ne
cons ol e a nd web opti on -wsport.
s ervi ces .
Extensions.Directory Di rectory for droppi ng Default: extensions Thi s repl a ced the
externa l bui l ti ns , obs ol ete pa ra meters
rewri ter, webs ervi ces a nd Extensions.Directory PathToBuiltinDir a nd
dyna mi c s ervi ce JAR fi l es . = c:/myextensions PathToRewriterDir.
186
OntoBroker 6.3 OntoBroker Server
-webservice Ena bl es OntoBroker web s ervi ce. Al terna ti vel y us e the pa ra meter
WebServi ces = on
-ajp Ena bl es OntoBroker web s ervi ce for l oa d ba l a nci ng. Al terna ti vel y us e the
pa ra meter AJP = on
-collabserver Ena bl es OntoBroker col l a bora ti on s erver (i mpl i ci tl y s ets Indexer = on);
a l terna ti vel y us e the pa ra meter Col l a bora ti onServer = on
-collabserverNoIndexer Ena bl es OntoBroker col l a bora ti on s erver (l ea ves Indexer s etti ngs
uncha nged)
-remoteAPI Thi s ha s nea rl y the s a me effect a s the opti on -col l a bs erver. The
OntoBroker i s tuned for query performa nce a nd s ome s peci a l
functi ona l i ti es needed for OntoStudi o a re not s wi tched on. Thi s mea ns
tha t a n OntoStudi o ca nnot us e thi s i ns ta nce a s a col l a bora ti on s erver. If
OntoBroker i s s ta rted wi th -remoteAPI i t beha ves a s a s ta nd a l one
s erver, i .e. the i nferenci ng mode i s turned off. Al terna ti vel y us e the
pa ra meter RemoteAPI = on
-fenc <encoding> Fi l e encodi ng us ed for rea di ng fi l es . (e.g. chi nes e codes a re "bi g5",
"cs Bi g5" a nd "i s o_i r-58"). Thi s i s neces s a ry when the fi l e encodi ng of a
concrete fi l e di ffers from the defa ul t of your opera ti ng s ys tem.
-diagnostics Wri tes i nforma ti on to the l og whi ch coul d hel p to a na l yze bugs .
Note:
If a pa ra meter ha s been s peci fi ed both i n the OntoConfi g a nd on the comma nd l i ne, the comma nd l i ne
opti on overrul es the OntoConfi g s etti ngs .
187
OntoBroker 6.3 OntoBroker Server
Exa mpl e:
start-ontobroker.cmd -webservice -collabserver -configFile OntoConfig.prp -m -flo
examples/flo/Unternehmen_US.obl -obl example/flo/Process_US.obl.
If the envi ronment va ri a bl e ONTOBROKER_HOME i s s et, i t i s pos s i bl e to run OntoBroker from a ny di rectory. As
OntoBroker l ooks i n the worki ng di rectory for OntoConfi g.prp, l og4j.properti es a nd for va ri ous fi l es i n the conf
s ubdi rectory by defa ul t, you ha ve to cha nge thes e defa ul ts expl i ci tl y or copy thes e fi l es i n your worki ng
di rectory.
Cha ngi ng l oca ti on of OntoConfi g.prp: us e the comma nd l i ne opti on -confi gFi l e <confi gFi l e>
Cha ngi ng l oca ti on of l og4j.properti es : s et the Ja va s ys tem envi ronment -Dl og4j.confi gura ti on=fi l e:
<fi l ena me>
Cha ngi ng l oca ti on of the conf di rectory: Expl i ci tl y s et the di r.conf pa ra meter i n the OntoConfi g.prp
The comma s epa ra ted a rgument l i s t i s provi ded a s term a rra y. Typi ca l l y, a comma nd returns a Stri ng, but i t
ca n theoreti ca l l y return a ny ki nd of Ja va object. However, there s ome res tri cti ons to cons i der:
If us i ng the method Ontol ogyMa na ger.execute from a col l a b s erver cl i ent, the returned cl a s s mus t be
known to the Col l a bs erver ma rs ha l l er. Thi s effecti vel y mea ns tha t onl y ba s i c Ja va da ta types a nd
col l ecti ons a nd cl a s s es genera ted by the KAON2Fa ctory ca n be us ed i n thi s ca s e.
If the comma nd i s executed by the s ocket protocol or OntoBroker web s ervi ce the res ul t i s a l wa ys
tra ns l a ted i nto a s tri ng by ca l l i ng toStri ng().
CommandProvider
188
OntoBroker 6.3 OntoBroker Server
In a ddi ti ona l l y to the comma nd cl a s s i ts el f you need a Comma ndProvi der s ervi ce, whi ch a nnounces the
comma nd(s ) to OntoBroker. Exa mpl e:
public class CommandProviderImpl implements CommandProvider {
@Override
public Collection<Class<? extends APICommand>> getCommands() {
ArrayList<Class<? extends APICommand>> list = new ArrayList<Class<? extends
APICommand>>();
list.add(MyCommand.class);
return list;
}
}
Thi s provi der mus t be regi s tered a s a n OSGi s ervi ce, e.g. defi ni ng a Decl a ra ti ve s ervi ce. Add to the OSGI-INF
di rectory of your pl ugi n a fi l e comma nds -provi der.xml :
<?xml version="1.0"?>
<component name="com.ontoprise.ontobroker.examples.api.commands">
<implementation class="com.yourcompany.x.y.CommandProviderImpl" />
<service>
<provide interface="com.ontoprise.api.command.CommandProvider"/>
</service>
</component >
The pa cka ge of the comma nd cl a s s mus t be exported from META-INF/ma ni fes t.mf of the pl ug-i n a nd the
s ervi ce component mus t a l s o be a dded to the ma ni fes t, e.g.
Service-Component: OSGI-INF/commands-provider.xml
Note:
Thi s opti on i s not s upported for OWL.
Synta x
-runscript <filename>
Exa mpl e
Thi s exa mpl e s hows how to i ns ert s ome fa cts , export the modul e, a nd exi t OntoBroker a utoma ti ca l l y.
ontobroker32.exe -runscript sample.oblcmd
sample.oblcmd
:- default prefix = "http://yourcompany.com#".
:- module m1.
189
OntoBroker 6.3 OntoBroker Server
delete The comma nd del ha s been removed s i nce Ontobroker 6.0. Ins tea d, pl ea s e us e the del ete
comma nd whi ch ha s a ri cher s ynta x.
Note:
It i s a l l owed to s peci fy query opti ons (s i nce OB 6.0 Bui l d 382).
delete Thi s comma nd ca n be us ed to del ete cl a us es (rul es , queri es , cons tra i nts ) by thei r l a bel .
clauses For exa mpl e to del ete the rul e wi th the i d r1 a nd the query wi th the i d q1:
delete clauses r1,q1
dump Wri tes a ful l dump of the extens i ona l a nd the i ntens i ona l da ta ba s e (i nterna l repres enta ti on).
190
OntoBroker 6.3 OntoBroker Server
The ta rget fol der i s the s o ca l l ed dump fol der where OntoBroker i s i ns ta l l ed.
exportAll Wri tes a dump of a l l modul es to the fi l es s ys tem. The ta rget fol der i s the fol der where
Modules OntoBroker i s i ns ta l l ed.
The comma nd "exportAl l Modul es " s upports a ddi ti ona l opti ons :
encrypt - modul es a re s a ved encrypted
s ort - fa cts of modul es a re s a ved i n s orted order
Note:
If, i n the comma nd l i ne, you s peci fy a di rectory to l oa d the ontol ogi es from l i ke "ontobroker -
obl decrypt:v1:di r", the decrypt ha ndl er fi rs t of a l l checks i f the fi l e i s encrypted. Exa mpl e:
ontobroker -obl decrypt:v1:C:\ontol ogi es .
Exa mpl e:
Sa ve modul es <http://yourcompa ny.com#ontol ogy1> to fi l e c:\da ta \onto1.obl wi th s orted opti on
save <http://yourcompany.com#ontology1> to "c:\\data\\onto1.obl",sort.
Sa ve modul es <http://yourcompa ny.com#ontol ogy1> to fi l e c:\da ta \onto1.obl wi th s ort a nd
encrypt opti on
save <http://yourcompany.com#ontology1> to "c:\\data\\onto1.obl",sort,
encrypt.
Export a l l modul es s orted
exportAllModules sort.
Export a l l modul es s orted a nd encrypted
exportAllModules sort,encrypt .
Note:
If "Seri a l i zerEs ca peNewLi nes = on" i s s et i n the OntoConfi g.prp, new l i ne cha ra cters i n s tri ng
cons ta nts a re es ca ped on s eri a l i za ti on (i .e. on comma nds l i ke "exportAl l Modul es " a nd
"s a ve").
generateD There a re now two comma nds for dyna mi c web s ervi ces :
ynamicSvc generateDynamicSvc "path-to-specification-module.obl".
The s tri ng a rgument mus t be a va l i d URL or pa th to the s peci fi ca ti on modul e fi l e.
a nd
deleteDynamicSvc <module>
Here <modul e> i s the modul e term of the s peci fi ca ti on modul e.
Note:
OntoBroker mus t ha ve been s ta rted wi th the "-webs ervi ce" opti on. The comma nd i s onl y
a va i l a bl e for Objectl ogi c.
Exa mpl e:
:- module echo.
:- prefix in = "http://schema.ontoprise.com/dynamic-svc/in#".
:- prefix out = "http://schema.ontoprise.com/dynamic-svc/out#".
:- prefix meta = "http://schema.ontoprise.com/dynamic-svc/meta#".
191
OntoBroker 6.3 OntoBroker Server
// Generation of Output
theResults:out#Results.
theResults[out#echo -> ?X] :- ?P:in#Parameters[in#message->?X].
h2 backup The s i ngl e a rgument s peci fi es the ta rget fi l ena me of the da ta ba s e copy.
<output- Thi s ba ckups the da ta ba s e fi l e to "d:\\ba ckup\\myba ckup.da ta .db"
name>
CAUTION:
All files like "d:\\backup\\mybackup.*" are deleted during the copy action to prevent the
possible mixing of old and new temporary database files.
Note:
The comma nd "h2ba ckup" i s onl y a va i l a bl e i f OntoBroker i s runni ng wi th H2 a s s tora ge.
Exa mpl e:
h2ba ckup "d:\\ba ckup\\myba ckup.da ta .db"
info Thi s comma nd checks s ome properti es a bout the rul es a nd fa cts a nd returns a (mul ti l i ne) i nfo
mes s a ge a bout the extens i ona l da ta ba s e (EDB, the fa cts ) a nd the i ntens i ona l da ta ba s e (IDB,
the rul es ). The output i s s i mi l a r to the output of the "ontol ogy checker" comma ndl i ne tool .
s ynta x: i nfo
Exa mpl e output:
------------------------------------------------------
IDB
------------------------------------------------------
[ ] program contains aggregation cycles (not allowed)
[ ] program is not bottomup evaluable (could be bad for performance)
[ ] program is not stratified and must be evaluated in wellfounded mode
(bad for performance)
[ ] program contains rules with cross products (bad for performance)
[ ] program contains rules which apply aggregations incorrectly (not
allowed)
# user rules: 0
# internal rules (including standard axioms): 48
# rules with negations: 3
# rules with aggregations: 0
# rules with connectors: 0
# rules with other builtins: 4
------------------------------------------------------
EDB: RAM.Packed (RAM.Packed)
# of tables: 1
------------------------------------------------------
1 tuples in obl:intern:module/1
...
192
OntoBroker 6.3 OntoBroker Server
insert The comma nd <a dd> ha s been removed s i nce Ontobroker 6.0. Pl ea s e us e the i ns ert comma nd
whi ch ha s a ri cher s ynta x i ns tea d. Here a re s ome exa mpl es of how to us e i ns ert i ns tea d of
a dd.
Ol d s ynta x i n OntoBroker 5.3:
add otto[name->"Otto"]. // syntax from OB 5.3, invalid in OntoBroker 6.1
add RULE r1: FORALL X p(X) <- q(X). // syntax from OB 5.3, invalid in
OntoBroker 6.1
In OntoBroker 6.1 the corres pondi ng comma nds a re:
insert otto[name->"Otto"].
insert {@{r1} p(?X) :- q(?X).}
The i ns ert comma nd i s us ed to a dd fa cts a nd rul es to a n ontol ogy. You ca n a dd mul ti pl e fa cts
or rul es wi th a s i ngl e comma nd i f you us e bra ces {...} a round them.
Exa mpl e wi th s i ngl e fa ct:
:- module <http://yourcompany.com/ontology1>.
insert Person[name *=> _string].
Exa mpl e wi th mul ti pl e fa cts a nd rul es :
:- module <http://yourcompany.com/ontology1>.
insert {
Person[name *=> _string, age {0:1} *=> _integer].
otto:Person[name -> "Otto Waalkers"].
fritz[name -> "Fritz", age->9].
@{rule1} ?X:Child :- ?X:Person, ?X.age < 18 .
}
Note:
You ca n a dd di recti ves for the modul e a nd na mes pa ce a l i a s a s a n hea der to the comma nd.
You ca n a l s o genera te a ddi ti ona l fa cts by i nferenci ng i f you a dd a where pa rt to the i ns ert
s ta tement. In thi s ca s e, a l l va ri a bl e bi ndi ngs res ul ti ng from the query of the where pa rt a re
repl a ced i n the i ns ert pa rt.
Si mpl e exa mpl e:
:- module <http://yourcompany.com/ontology1>.
insert { ?X[lovesToys->true]. } where { ?- ?X:Child. }
As s umi ng tha t the res ul ts of the query ?- ?X:Chi l d a re fri tz a nd s us a n, thi s exa mpl e woul d
i ns ert the fa cts fri tz[l oves Toys ->true] a nd s us a n[l oves Toys ->true].
kill Ki l l s the s erver. Beha ves l i ke s hutdown now, but ends the OntoBroker proces s a fter 70 s econds
i f "s hutdown now" wa s not s ucces s ful wi thi n thi s ti me. Al s o s ee the s hutdown comma nd for
a l terna ti ve beha vi or.
s ynta x: ki l l
OntoBroker Return Va l ues : i nference s erver s hutti ng down NOW ...
modify Wi th the modi fy comma nd you ca n a dd a nd remove fa cts i n a s i ngl e s tep. As the va ri a bl e
bi ndi ngs of the where pa rt a re us ed for both i ns ert a nd del ete, thi s ca n be qui te us eful a nd i s
ea s i l y covered by s epa ra te del ete a nd i ns ert comma nds .
Exa mpl e:
// increment the age of all age attributes for persons
modify delete { ?P[age->?AGE]. } insert { ?P[age->?NEWAGE]. } where { ?- ?
P:Person[age->?AGE], ?NEWAGE=?AGE + 1 .}
193
OntoBroker 6.3 OntoBroker Server
removeExp Removes a n expl a na ti on wi th the gi ven na me. If no expl a na ti on exi s ts no error i s reported.
lanation s ynta x: removeExpl a na ti on <expl a na ti on modul e>
OntoBroker Return Va l ues : Modul e prooftreefa cts _(<modul e1>) del eted
stopQuery Sets a n i nterrupt fl a g for the currentl y runni ng query wi th the gi ven querykey. The query wi l l
s top i n a control l ed wa y.
The a rgument <querykey> i denti fi es the query to s top. Thi s va l ue i s returned i mmedi a tel y a fter
s ta rti ng a query comma nd.
s ynta x: s topquery <querykey>
OntoBroker Return Va l ues : "Interrupt fl a g s et" or "No query found for querykey <querykey>"
Check for Thi s comma nd checks i f a n OWL ontol ogy i s conforma nt wi th the OWL RL profi l e.
OWL 2 RL Synta x: checkOWLRLProfi l e <ontol ogy-uri >
profile
Ea ch found vi ol a ti on of the OWL RL profi l e i s l i s ted a s output.
Connector Thi s comma nd cl ea ns a connector ca che. Thi s comma nd ca n be executed onl y i f Ontobroker i s
cache s ta rted wi th the opti on Connector.*.Ca che.Li feti me = unl i mi ted.
clear Synta x: cl ea r_connector_ca che a l l | ca che key
command
a l l - a l l tupl es wi l l be del eted from the ca che.
ca che key - onl y tupl es for the ca che key wi l l be del eted. Ca che key i s a ma p term a nd ca n
conta i n di fferent va l ues for di fferent connectors .
saveSessi Thi s comma nd s a ves a l l s es s i on fa cts a nd a ttri butes to the gi ven fi l ena me
onSnapsho To encrypt the s es s i on us e: s a veSes s i onSna ps hot "fi l ena me", encrypt.
t
Synta x: s a veSes s i onSna ps hot "fi l ena me".
loadSessi Thi s comma nd l oa ds a l l s es s i on fa cts a nd a ttri butes from the gi ven fi l ena me.
onSnapsho Synta x: l oa dSes s i onSna ps hot "fi l ena me".
t
Note:
Prepa red queri es a re not s upported when a cces s control (rol e-ba s ed s ecuri ty) i s ena bl ed.
194
OntoBroker 6.3 OntoBroker Server
Prepa red queri es ca n be ma i nta i ned wi th the fol l owi ng comma nds :
preparequery
removepreparedquery
preparedquerylist
preparequery Sends the gi ven query to preparequery Progra m prepa red for
the s erver. The na me wi l l {temporary facts query: <queryna me>
be us ed to i denti fy the { {flogic-query
query for further us a ge i n { [fillnull]
comma nds .
Executi ng a prepa red query [temporary facts] Executes a query wi th the gi ven
[substitute na me. If no prepa red query i s
A prepa red query i s executed l i ke (<substitutions>)@pq.] a va i l a bl e a n error i s reported.
a norma l query, but a s peci a l ?- <vars> <- PREPARED_QUERY Tempora ry fa cts a re a dded to the
s ynta x i s us ed. (<queryname>,<vars>). EDB for thi s query i f gi ven.
[<query options>] Appended query opti ons
?- ?X:?Y. (orderedby etc.) work a s defi ned. If
the prepa red query conta i ns
s ubs ti tuti ons , the va l ues for thes e
pl a cehol ders a re provi ded by the
s peci a l tempora ry fa ct wi th the
predi ca te "s ubs ti tute". Thi s a l l ows
s peci a l cons ta nts to be repl a ced
a s defi ned i n (1) wi th concrete
195
OntoBroker 6.3 OntoBroker Server
196
OntoBroker 6.3 OntoBroker Server
Command Description
opt_genetic status The return va l ue i s a s tri ng. The s ta tus of the l a s t compl ete genera ti on wi l l be
returned.
At l ea s t one genera ti on ha s to be eva l ua ted before va l i d res ul ts ca n be del i vered.
OntoBroker Return Va l ues : The return va l ue i s a "s tri ng" wi thout l i ne s epa ra tors .
Us e | a s s epa ra ti on cha ra cter.
opt_genetic kill Stops a runni ng opti mi za ti on. It ma y ta ke a s hort ti me, you ca n us e the -
i s opti mi zi ng comma nd to s ee when i t i s done. The ti meout wi ndow ha s to fi t i nto
the ti meout of the s ocket connecti on, s o i t ma y be to s ma l l for s ome ca s es .
Options Description
19.3.3.2 Hillclimbing
The comma nd
opt_hillclimbing <queryID>
opti mi zes the bodyorderi ng us i ng a hi l l cl i mbi ng a l gori thm. You ca n cha nge the orderi ng ma nua l l y.
Us a ge:
opt_hillclimbing [file, filename], [rewrite], module, modulename, queryID
opt_hillclimbing isoptimizing
opt_hillclimbing kill
opt_hillclimbing status
Exa mpl e:
opt_hillclimbing file, "test.data", rewrite, module, "<http://www.NewOnto1.org/
ontology>", "queryID"
Options Description
It i s di s pl a yed a s pl a i n text i n the fi l e bodyorderi ng.da ta . You ca n rena me the fi l e i n OntoConfi g.prp:
197
OntoBroker 6.3 OntoBroker Server
BodyOrderingDataFile = mybodyordering.data
Addi ti ona l i nforma ti on a bout the hi l l cl i mbi ng a l gori thm:
Hi l l cl i mbi ng ca n be us ed to s ol ve probl ems tha t ha ve ma ny s ol uti ons , s ome of whi ch a re better tha n others .
It s ta rts wi th a ra ndom (potenti a l l y poor) s ol uti on, a nd i tera ti vel y ma kes s ma l l cha nges to the s ol uti on,
i mprovi ng i t a l i ttl e ea ch ti me. When the a l gori thm ca nnot s ee a ny more i mprovements , i t termi na tes . Idea l l y,
a t tha t poi nt the current s ol uti on i s cl os e to opti ma l , but i t i s not gua ra nteed tha t hi l l cl i mbi ng wi l l ever come
cl os e to the opti ma l s ol uti on.
19.3.3.3 record_bodyordering
Wi th the comma nd record_bodyordering <query id> you a re a bl e to record the bodyorderi ng. It i s di s pl a yed a s
pl a i n text i n the fi l e bodyorderi ng.da ta . You ca n rena me the fi l e i n OntoConfi g.prp:
BodyOrderingDataFile = mybodyordering.data
The fi l e i s equa l to a l l opti mi zer fi l es a nd i s di s pl a yed a s fol l ows :
Synta x:
record_bodyordering <http://www.NewOnto4.org/Test#query>
Fi rs t, the query i s s hown, a nd then the eva l ua ti on method a nd then, for ea ch rul e, the di fferent orderi ngs for
di fferent va ri a bl es .
{} [2,0,1] //e.g. means no variable instantiation, then the ordering is 2,0,1
{0} [0,1,2] // e.g. means that the first variable is instantiated in the body
then we have the ordering 0,1,2
Note:
The di rectory of the fi l e depends on the us ed OntoConfi g.prp: i f you us e the OntoConfi g.prp from c:/
Ontoconfi g.prp, the bodyorderi ng.da ta wi l l be wri tten i n c:/conf/.
Option Description
FULL Confi gura ti on opti mi za ti on wi th genera ti on of ti me s ta ti s ti cs . Al l confi gura ti ons a re tes ted.
The executi on ti me a nd s peed up fa ctor for a l l confi gura ti ons a re di s pl a yed.
QUICK Confi gura ti on opti mi za ti on wi thout genera ti on of ti me s ta ti s ti cs . Al l confi gura ti ons a re tes ted
but onl y the fa s tes t confi gura ti on i s di s pl a yed.
DBACCESS Qui ck confi gura ti on opti mi za ti on for externa l da ta ba s e a cces s . Onl y confi gura ti ons wi th a
mi ni ma l number of dba cces s us er a re tes ted. It's not gua ra nteed tha t the propos ed
confi gura ti on wi l l be opti ma l .
198
OntoBroker 6.3 OntoBroker Server
Drop Module
Delete Rule
199
OntoBroker 6.3 OntoBroker Server
OntoBrokerConnectionManager.getConnection(…)
import org.semanticweb.kaon2.api.OntologyManager;
import org.semanticweb.kaon2.api.SessionManager;
import org.semanticweb.kaon2.api.SessionFacade;
OntologyManager om = …;
SessionManager sm = om.getSessionManager();
SessionFacade sf = sm.createSession(…);
Note:
In OntoBroker 6.1 the s es s i ons of the Col l a bora ti on s erver a re a di fferent ki nd of s es s i on a nd ca nnot be
us ed i n the wa y des cri bed a bove.
200
OntoBroker 6.3 OntoBroker Server
Commands
Severa l comma nds ha ve been extended for us a ge wi th s es s i ons . The INSERT, DELETE a nd MODIFY comma nds
ca n now opti ona l l y work on the s es s i on fa cts by a ddi ng a "INTO SESSION" or "FROM SESSION" to the comma nd.
Exa mpl es :
INSERT INTO SESSION { alice:Person[age->18]. }
DELETE FROM SESSION { alice:Person[age->18]. }
MODIFY DELETE FROM SESSION { ?P[age->?X0]. }
INSERT INTO SESSION { ?P[age->?X1]. }
WHERE { ?- ?P[age->?X0], ?X1 = ?X0 + 1. }
Va ri a nts of modi fy ca n a l s o be us ed for movi ng da ta between s es s i on a nd s ta ti c s tora ge
MODIFY DELETE {...} INSERT INTO SESSION {...} WHERE {...}
MODIFY DELETE FROM SESSION {...} INSERT {...} WHERE {...}
For s etti ng s es s i ons a ttri bute there i s a new SET comma nd:
set default prefix = "http://ontoprise.de/".
set prefix a = "http://ontoprise.de/sg#".
set default module = inferencelayer.
Thes e defa ul t na mes pa ce, na mes pa ce prefi x a nd defa ul t modul e a ttri butes ca n be us ed i n s ubs equent
comma nds a nd queri es wi thout needi ng to s ta te them a ga i n.
Built-ins
There a re two bui l t-i ns to dea l wi th s es s i ons : _a cti veSes s i ons /4 a nd _s es s i onInfo/1
_activeSessions/4
Thi s bui l t-i n returns a l l OntoBroker a nd Col l a bora ti on s erver s es s i ons .
Exa mpl e:
?- _activeSessions(?Id,?Type,?User,?Host).
201
OntoBroker 6.3 OntoBroker Server
_sessionInfo/1
Thi s bui l t-i n returns i nforma ti on on the current s es s i on, l i ke the defa ul t modul e, defa ul t na mes pa ce a nd
other na mes pa ce prefi xes , a nd number of fa cts i n the s es s i on EDB.
Exa mpl e:
?- _sessionInfo(?InfoMap) .
The bui l t-i n returns a ma p wi th fol l owi ng key va l ue pa i rs :
Key Value
"i d" s es s i on i d
"us er" us er na me
_loginUser/2
Thi s bui l t-i n i s not new, but i f the us er na me wa s provi ded on s es s i on crea ti on, i t returns us er na me a nd
hos t.
Exa mpl e:
?- _loginUser(?User, ?Host).
Limitations
Ses s i ons ca n onl y s tore fa cts , i .e. i t ca nnot s tore rul es , queri es or cons tra i nts .
It i s onl y pos s i bl e to del ete fa cts of the s es s i on, but not to hi de s ta ti c fa cts . i .e. i f a fa ct i s s tored i n the
s ta ti c s tora ge of OntoBroker, del eti ng i t from the s es s i on ha s no effect.
Ses s i ons ca n onl y s tore fa cts i n exi s ti ng modul es , i .e. a t l ea s t one fa ct or rul e mus t exi s t i n thi s modul e
i n the s ta ti c s tora ge of OntoBroker.
Pers i s tence of s es s i ons i s not s upported i n OntoBroker 6.1, i .e. s es s i on fa cts a re onl y hel d i n the
memory.
Syntax
runGroovyScript "pathToScript",arg1,...
The runGroovyScri pt comma nd ta kes a t l ea s t one a rgument. The fi rs t a rgument i s the pa th to the Groovy s cri pt,
rel a ti ve to the groovy s ubdi rectory of the extens i ons di rectory, i .e. the Extens i ons .Di rectory property of the
OntoConfi g.prp. By defa ul t thi s i s l oca ted a t $ONTOBROKER_HOME/extens i ons /groovy.
202
OntoBroker 6.3 OntoBroker Server
Arguments
You ca n s peci fy more comma -s epa ra ted a rguments . Thes e a re jus t forwa rded to the s cri pt i n the va ri a bl e a rgs
a s Term objects . a rgs [0] i s a l wa ys the s cri pt na me i ts el f. Exa mpl e:
runGroovyScript "myscript.groovy",1.0,2.0 .
Bindings
You ca n us e the fol l owi ng predefi ned va ri a bl e bi ndi ngs i n the Groovy s cri pt:
ontol ogyMa na ger The i ns ta nce of org.s ema nti cweb.ka on2.a pi .Ontol ogyMa na ger
a rgs The comma nd a rguments a s org.s ema nti cweb.ka on2.a pi .l ogi c.Term a rra y (a rgs [0] i s the
s cri pt na me)
comma nd Cl os ure to execute a comma nd. It expects exa ctl y one s tri ng a rgument conta i ni ng the
comma nd i n ObjectLogi c s ynta x.
Exa mpl e:
comma nd("i ns ert a [b->c]@m1.")
A query fi l e conta i ns a query (a s you woul d type one i n the Web cons ol e):
:- prefix b = "http://www.ontoprise.com/ontologies#".
:- module = b#ontowebtravel.
:- default prefix = "http://www.ontoprise.com/ontologies/ontowebtravel#".
?- ?X:?Y.
When you execute the query fi l e you get your res ul ts a s us ua l (thi s exa mpl e us es the "tra vel " exa mpl e
ontol ogy):
X Y
----------
<http://www.ontoprise.com/ontologies/ontowebtravel#h2> <http://www.ontoprise.com/
ontologies/ontowebtravel#Hotel>
<http://www.ontoprise.com/ontologies/ontowebtravel#john> <http://www.ontoprise.
com/ontologies/ontowebtravel#Customer>
<http://www.ontoprise.com/ontologies/ontowebtravel#d2> <http://www.ontoprise.com/
ontologies/ontowebtravel#Date>
203
OntoBroker 6.3 OntoBroker Server
<http://www.ontoprise.com/ontologies/ontowebtravel#d3> <http://www.ontoprise.com/
ontologies/ontowebtravel#Date>
<http://www.ontoprise.com/ontologies/ontowebtravel#d1> <http://www.ontoprise.com/
ontologies/ontowebtravel#Date>
<http://www.ontoprise.com/ontologies/ontowebtravel#washington> <http://www.
ontoprise.com/ontologies/ontowebtravel#City>
<http://www.ontoprise.com/ontologies/ontowebtravel#madrid> <http://www.ontoprise.
com/ontologies/ontowebtravel#City>
<http://www.ontoprise.com/ontologies/ontowebtravel#newyork> <http://www.ontoprise.
com/ontologies/ontowebtravel#City>
<http://www.ontoprise.com/ontologies/ontowebtravel#t1> <http://www.ontoprise.com/
ontologies/ontowebtravel#Transport>
<http://www.ontoprise.com/ontologies/ontowebtravel#h1> <http://www.ontoprise.com/
ontologies/ontowebtravel#Hotel>
<http://www.ontoprise.com/ontologies/ontowebtravel#h2> <http://www.ontoprise.com/
ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#washington> <http://www.
ontoprise.com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#madrid> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#newyork> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#h1> <http://www.ontoprise.com/
ontologies/ontowebtravel#Location>
But i t i s a l s o pos s i bl e to a bbrevi a te the na mes pa ce terms wi th the na mes pa ces gi ven i n the query text:
query.cmd -queryFile myQueryFile.obl -abbreviateNamespaces
If you a ddi ti ona l l y s peci fy the "-forma tti ng" opti on then the res ul t wi l l be forma tted to be ea s i l y rea da bl e.
However, i n thi s ca s e, the whol e query wi l l be executed before the res ul t wi l l be pri nted. The res ul t l ooks
l i ke thi s :
X Y
---------------------
h2 Hotel
john Customer
d2 Date
d3 Date
d1 Date
washington City
madrid City
newyork City
t1 Transport
h1 Hotel
h2 Location
washington Location
204
OntoBroker 6.3 OntoBroker Server
madrid Location
newyork Location
h1 Location
If you prefer to get the res ul t wi thout a bbrevi a ted na mes pa ces , but forma tted the res ul t l ooks l i ke thi s :
X Y
-------------------------------------------------------------------------------------
----------------------------------------
<http://www.ontoprise.com/ontologies/ontowebtravel#h2> <http://www.ontoprise.
com/ontologies/ontowebtravel#Hotel>
<http://www.ontoprise.com/ontologies/ontowebtravel#john> <http://www.ontoprise.
com/ontologies/ontowebtravel#Customer>
<http://www.ontoprise.com/ontologies/ontowebtravel#d2> <http://www.ontoprise.
com/ontologies/ontowebtravel#Date>
<http://www.ontoprise.com/ontologies/ontowebtravel#d3> <http://www.ontoprise.
com/ontologies/ontowebtravel#Date>
<http://www.ontoprise.com/ontologies/ontowebtravel#d1> <http://www.ontoprise.
com/ontologies/ontowebtravel#Date>
<http://www.ontoprise.com/ontologies/ontowebtravel#washington> <http://www.ontoprise.
com/ontologies/ontowebtravel#City>
<http://www.ontoprise.com/ontologies/ontowebtravel#madrid> <http://www.ontoprise.
com/ontologies/ontowebtravel#City>
<http://www.ontoprise.com/ontologies/ontowebtravel#newyork> <http://www.ontoprise.
com/ontologies/ontowebtravel#City>
<http://www.ontoprise.com/ontologies/ontowebtravel#t1> <http://www.ontoprise.
com/ontologies/ontowebtravel#Transport>
<http://www.ontoprise.com/ontologies/ontowebtravel#h1> <http://www.ontoprise.
com/ontologies/ontowebtravel#Hotel>
<http://www.ontoprise.com/ontologies/ontowebtravel#h2> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#washington> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#madrid> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#newyork> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
<http://www.ontoprise.com/ontologies/ontowebtravel#h1> <http://www.ontoprise.
com/ontologies/ontowebtravel#Location>
205
OntoBroker 6.3 OntoBroker Tool s
20 OntoBroker Tools
You ca n fi nd a l l of the tool s cri pts i n the "tool s " s ubdi rectory of your OntoBroker i ns ta l l a ti on.
206
OntoBroker 6.3 OntoBroker Tool s
If us i ng rel a ti ve pa ths , thes e pa ths mus t be i n rel a ti on to the s ta rtup di rectory from where the benchma rk i s
run.
Exa mpl e:
<ontobrokerBenchmark>
<property name="benchmarksuite.config.dir" value="resources/testfiles/
performancetest/testsuites/benchmarksuite/configurations" />
<property name="benchmark_files.dir" value="resources/testfiles/performancetest/
testsuites/benchmarksuite/benchmarks/benchmark_files" />
<!-- ====================================================
Format since OntoBroker 6.1
==================================================== -->
<suite name="Graph1M">
<arguments>-obl ${bigfiles.base.dir}/gptInterfaceTest/graph1000000.obl</arguments
>
<!-- New: Use attribute "name" and "file" instead of xml element "configName"
and "configFile" -->
<configuration name="BU/BU2" file="${benchmarksuite.config.dir}/BU_BU2.prp" />
<configuration name="BU/DBBU" file="${benchmarksuite.config.dir}/BU_DBBU.prp" /
>
<configuration name="BU/BU3" file="${benchmarksuite.config.dir}/BU_BU3.prp" />
<!-- ====================================================
Format before OntoBroker 6.1 - still valid!
==================================================== -->
<suite>
<name>Graph1M_nofunc</name>
<arguments>-obl ${bigfiles.base.dir}/gptInterfaceTest/graph1000000nofunctions.obl
</arguments>
<queryfile>${benchmark_files.dir}/GPT.queries.obl</queryfile>
<configurations>
<configuration>
<configName>BU/BU2</configName>
<configFile>${benchmarksuite.config.dir}/BU_BU2.prp</configFile>
</configuration>
<configuration>
<configName>BU/DBBU</configName>
<configFile>${benchmarksuite.config.dir}/BU_DBBU.prp</configFile>
</configuration>
<configuration>
<configName>BU/BU3</configName>
<configFile>${benchmarksuite.config.dir}/BU_BU3.prp</configFile>
</configuration>
<configuration>
<configName>DF2</configName>
<configFile>${benchmarksuite.config.dir}/DF2.prp</configFile>
</configuration>
</configurations>
</suite>
</ontobrokerBenchmark>
207
OntoBroker 6.3 OntoBroker Tool s
The s ui te's na me ta g mus t be uni que for the benchma rk confi gura ti on
The a rguments ta g mus t conta i n the l oa ded ontol ogi es (e.g. -fl o ...), other s ta rtup pa ra meters a re a l l owed
The queryfi l e ta g mus t conta i n the pa th to a text fi l e whi ch conta i ns the queri es ; wi thi n thi s query fi l e the
queri es mus t be wri tten one per l i ne
The confi gNa me ta g mus t be uni que wi thi n the <s ui te> pa rt but ca n be reus ed i n di fferent s ui tes
The confi gFi l e ta g mus t conta i n the pa th to a OntoBroker confi gura ti on fi l e
Argument Function
benchmark.cmd <benchmarksuiteFileName> s tores the res ul ts a t defa ul t output di rectory
<benchma rks ui teFi l eNa me>_output\
benchmark.cmd <benchmarksuiteFileName> s tores the res ul ts a t the gi ven output di rectory
<benchmarksuiteOutputDir>
benchmark.cmd <benchmarksuiteFileName> - del etes the defa ul t output di rectory
clean (<benchma rks ui teFi l eNa me>_output\)
benchmark.cmd <benchmarksuiteFileName> - del etes the gi ven output di rectory
clean <benchmarksuiteOutputDir>
The provi ded exa mpl e benchma rk ca n be run vi a thi s comma nd:
tools/benchmark.cmd benchmark/benchmark.xml
Note:
The output forma t i s gi ven by the ta rget fi l ena me.
208
OntoBroker 6.3 OntoBroker Tool s
Note:
Thi s wi l l not res ul t i n a s ma l l er da ta ba s e fi l e. To s hri nk the H2 da ta ba s e fi l e, a n expl i ci t da ta ba s e
compa cti on ha s to be performed. See H2 da ta ba s e webs i te for deta i l s .
209
OntoBroker 6.3 Appendi x
21 Appendix
21.1 Ontology Transformation
Tra ns formi ng ObjectLogic into RDF Schema i s i n mos t ca s es s tra i ghtforwa rd. Ba s i ca l l y every ObjectLogi c fa ct i s
repres ented a s one (or more) RDF tri pl e. Whenever a functi ona l term occurs , i t i s ma pped to a n IRI us i ng the
predefi ned na mes pa ce 'obl :term#':
<myns:myFunction>(arguments) <=> <obl:term#%3Cmyns:myFunction%3E(arguments)>
Whi l e ObjectLogi c a l l ows cons ta nts of every type a s object i denti fi ers , RDF i mpos es s evera l res tri cti ons on
the s tructure of s ta tements . For exa mpl e, a nonymous nodes a re not a l l owed a s a predi ca te i n RDF
s ta tements . Al l of the ObjectLogi c fa cts not conformi ng to thi s res tri cti on a re di s ca rded.
For every tra ns forma ti on a s umma ry l og i s provi ded. It s hows potenti a l tra ns forma ti on probl ems l i ke a xi oms
not s upported i n the ta rget ontol ogy l a ngua ge.
Schema
ObjectLogi c concept a nd property hi era rchi es a re di rectl y tra ns formed i nto the RDF Schema cl a s s hi era rchy. For
a ttri bute a nd rel a ti on defi ni ti ons , the RDF Schema el ements doma i n a nd ra nge a re us ed. Thi s i ntenti ona l
brea k wi th the RDF Schema s ema nti cs i nterpreti ng doma i n a nd ra nge a s cons tra i nts fa vors a more
"i nforma ti on pres ervi ng" i ns tea d of a s ema nti ca l l y correct tra ns forma ti on.
The gl oba l defi ni ti on of properti es i n RDF, i n contra s t to concept-bound i n ObjectLogi c, i mpl i es tha t
a ttri butes /rel a ti on us i ng the s a me i denti fi er wi l l be merged duri ng the tra ns forma ti on, i .e. they s ha re the
s a me doma i n a nd ra nge defi ni ti ons .
Fi na l l y, properti es of a ttri butes /rel a ti ons l i ke ca rdi na l i ty res tri cti ons , tra ns i ti vi ty, s ymmetry, a nd i nvers e-of
defi ni ti ons a re not s upported by the RDF Schema . If thi s i nforma ti on needs to be ta ken i nto a ccount, a n
tra ns forma ti on to OWL s houl d be cons i dered. For the RDF Schema onl y the decl a ra ti on of the a ttri bute/
rel a ti on i ts el f i s s tored.
Person[]. <=> :Person a rdfs:Class.
Person::Human. <=> :Person rdfs:subClassOf :Human.
loves<<knows. <=> :loves rdfs:subPropertyOf :knows.
Person[name{1:2}*=>_string]. => :name rdfs:domain :Person; rdfs:range xsd:
string.
Person[p{symmetric}*=>()]. => :p a rdf:Property.
Person[p{transitive}*=>()]. => :p a rdf:Property.
Person[p{transitive}*=>()]. => :p a rdf:Property.
Person[p{inverseOf(q)}*=>()]. => :p a rdf:Property. :q a rdf:Property.
Instances
As s erti ons , both for i ns ta nces a nd concepts , a re tra ns formed pres ervi ng the da ta type.
eve:Person. <=> :eve a :Person.
eve[name->"Eve"]. <=> :eve :name "Eve"^^xsd:string.
eve[name->"Eve@"^^_PlainLiteral]. <=> :eve :name "Eve".
eve[name->"Evita@es"^^_PlainLiteral]. <=> :eve :name "Evita"@es.
eve[p->true]. <=> :eve :p "true"^^xsd:boolean.
eve[p->1]. <=> :eve :p "1"^^xsd:int.
eve[p->2.3]. <=> :eve :p 2.3e0 .
eve[p->"4.0"^^_decimal]. <=> :eve :p 4.0 .
eve[p->"11:55:32"^^_time]. <=> :eve :p "11:55:32"^^xsd:time.
210
OntoBroker 6.3 Appendi x
Schema
Cl a s s a nd property decl a ra ti ons a nd concept a nd property hi era rchi es a re tra ns formed i nto ObjectLogi c
equi va l ent fa cts .
:Person a rdfs:Class. <=> Person[].
:Person rdfs:subClassOf :Human. <=> Person::Human.
:knows a rdf:Property. <=> _property(knows).
:loves rdfs:subPropertyOf :knows. <=> loves<<knows.
The tra ns forma ti on of doma i n a nd ra nge defi ni ti ons i s s l i ghtl y more compl ex. Al l of the rel a ted doma i n/
ra nge i nforma ti on i s col l ected for every RDF property. Properti es not conta i ned i n a t l ea s t one doma i n a nd i n
one ra nge defi ni ti on s ta tement a re i gnored. Al l other properti es a re i nterpreted a s s chema res tri cti ons ,
whi ch i s s ema nti ca l l y not correct, however the bes t tra de-off i n terms of round-tri ppi ng.
For exa mpl e, the tri pl es
:age rdfs:domain :Person.
:age rdfs:domain :Building.
:age rdfs:range xsd:double.
:name rdfs:range xsd:string.
wi l l be tra ns formed i nto ObjectLogi c
Person[age*=>_double].
Building[age*=>_double].
Instances
Ins ta nce decl a ra ti ons a nd genera l a s s erti ons a re tra ns formed pres ervi ng the da ta type.
:eve a :Person. <=> eve:Person.
:eve :name "Eve"^^xsd:string. <=> eve[name->"Eve"].
:eve :name "Eve". <=> eve[name->"Eve@"^^_PlainLiteral].
:eve :name "Evita"@es. <=> eve[name->"Evita@es"^^_PlainLiteral].
:eve :p "true"^^xsd:boolean. <=> eve[p->true].
:eve :p 1 . <=> eve[p->1].
:eve :p 2.3e0 . <=> eve[p->2.3].
:eve :p 4.0 . <=> eve[p->"4.0"^^_decimal].
:eve :p "11:55:32"^^xsd:time. <=> eve[p->"11:55:32"^^_time].
:eve :p "foo"^^my:type. ==> eve[p->"foo"].
211
OntoBroker 6.3 Appendi x
property.
Si nce ObjectLogi c does not expl i ci tl y ma rk the us ed terms wi th a n enti ty type, there a re a mbi gui ti es , e.g. i n 'a
[p->b]' i t i s not cl ea r i f 'b' i s mea nt to be a n i ndi vi dua l or a cons ta nt, thereby i t i s not cl ea r i f thi s fa ct s houl d
be tra ns l a ted to a n ObjectPropertyAs s erti on or a Da ta PropertyAs s erti on.
The tra ns forma ti on tri es to detect the property types for terms a nd tra ns l a tes the fa cts a ccordi ngl y. For
exa mpl e, i f the ontol ogy conta i ns a s chema fa ct 'A[p*=>B]' where B does not i denti fy a s ta nda rd da ta type, i t
a s s umes tha t 'p' i s a n object property. If i ns tea d 'A[p*=>_s tri ng]' i s conta i ned i n the ontol ogy, the
tra ns forma ti on a s s umes tha t 'p' i s a da ta property. If both s chema fa cts a re i ncl uded, there i s a confl i ct a nd
the tra ns forma ti on ha ndl es the type of 'p' a ccordi ng to the context.
Property Attributes
ObjectLogi c bi nds property a ttri butes to s ome concepts , e.g. 'A[p{s ymmetri c}*=>()]' bi nds 'p' to 'A'. In OWL thi s
i s not (di rectl y) pos s i bl e a nd the tra ns forma ti on s ki ps the i nforma ti on a bout the concept, i .e. wi l l jus t decl a re
'p' to be s ymmetri c, s o 'A' i s a doma i n for 'p' (ObjectPropertyDoma i n(p A).
Inheritance
Ba s i ca l l y A[p=>B] i s i gnored. Certa i nl y i t i s a s ked to a ppropri a te the type of 'p'. In thi s ca s e 'p' i s decl a red a s
a n ObjectProperty.
212
OntoBroker 6.3 Appendi x
213
OntoBroker 6.3 Appendi x
214
OntoBroker 6.3 Appendi x
Data Ranges
Da ta ra nges bes i des pl a i n da ta types a re uns upported.
Basic Transformations
The fol l owi ng ta bl e s hows the ba s i c tra ns forma ti on under 'na tura l ' a s s umpti ons , i gnori ng s evera l s peci a l
ca s es . Axi oms not l i s ted here a re uns upported.
The tra ns forma ti on requi res tha t A ha s been detected a s a n object property doma i n for the object property p
a nd B a s object property doma i n of the object property r. Uns upported a xi oms a re s ki pped by the
tra ns forma ti on.
ClassAssertion(A a) => a:A.
215
OntoBroker 6.3 Appendi x
na med cl a s s CN CN
CN
i nters ecti on ObjectInters ecti onOf(C1 … Cn) _Inters ecti onOf([C1, C2, …,Cn])
_:x rdf:type owl :Cl a s s .
_:x owl :i nters ecti onOf ( C1 … Cn ).
216
OntoBroker 6.3 Appendi x
exa ct ca rdi na l i ty ObjectExa ctCa rdi na l i ty(n P) _Exa ctCa rdi na l i ty(n, P, owl #Thi ng)
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :ca rdi na l i ty n.
qua l i fi ed exa ct ObjectExa ctCa rdi na l i ty(n P C) _Exa ctCa rdi na l i ty(n, P, C)
ca rdi na l i ty
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :qua l i fi edCa rdi na l i ty n.
_:x owl :onCl a s s C.
ma xi mum ObjectMa xCa rdi na l i ty(n P) _Ma xCa rdi na l i ty(n, P, owl #Thi ng)
ca rdi na l i ty
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :ma xCa rdi na l i ty n.
mi ni mum ObjectMi nCa rdi na l i ty(n P) _Mi nCa rdi na l i ty(n, P, owl #Thi ng)
ca rdi na l i ty
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :mi nCa rdi na l i ty n.
217
OntoBroker 6.3 Appendi x
218
OntoBroker 6.3 Appendi x
exa ct ca rdi na l i ty Da ta Exa ctCa rdi na l i ty(n R) _Exa ctCa rdi na l i ty(n, R, rdfs #Li tera l )
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :ca rdi na l i ty n.
qua l i fi ed exa ct Da ta Exa ctCa rdi na l i ty(n R D) _Exa ctCa rdi na l i ty(n, R, D)
ca rdi na l i ty
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :qua l i fi edCa rdi na l i ty n.
_:x owl :onDa ta Ra nge D.
ma xi mum Da ta Ma xCa rdi na l i ty(n R) _Ma xCa rdi na l i ty( n, R, rdfs #Li tera l )
ca rdi na l i ty
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :ma xCa rdi na l i ty n.
mi ni mum Da ta Mi nCa rdi na l i ty(n R) _Mi nCa rdi na l i ty(n, P, rdfs #Li tera l )
ca rdi na l i ty
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :mi nCa rdi na l i ty n.
219
OntoBroker 6.3 Appendi x
Properties
na med object PN PN
property PN
na med da ta R R
property
R
220
OntoBroker 6.3 Appendi x
na med aN
i ndi vi dua l
aN
Data Ranges
na med da ta type DN DN
DN
da ta type Da ta typeRes tri cti on(DN f1 v1 … fn vn) _Da ta typeRes tri cti on(DN, [f1, v1, … fn, vn])
res tri cti on
_:x rdf:type rdfs :Da ta type.
_:x owl :onDa ta type DN.
_:x owl :wi thRes tri cti ons (_:x1 ... _:xn).
_:xj fj vj. j=1…n
Axioms
OWL 2 RL s upports a l l a xi oms of OWL 2 a pa rt from di s joi nt uni ons of cl a s s es (Di s joi ntUni on) a nd refl exi ve
object property a xi oms (Refl exi veObjectProperty).
221
OntoBroker 6.3 Appendi x
equi va l ent Equi va l entCl a s s es (C1 C2) _Equi va l entCl a s s es (C1, C2)
cl a s s es
C1 owl :equi va l enCl a s s C2.
di s joi nt cl a s s es Di s joi ntCl a s s es (C1 C2) _Di s joi ntCl a s s es (C1, C2)
C1 owl :di s joi ntWi th C2.
pa i rwi s e di s joi nt Di s joi ntCl a s s es (C1 … Cn) _Di s joi ntCl a s s es 1([C1,…, Cn ])
cl a s s es
_:x rdf:type owl :Al l Di s joi ntCl a s s es .
_:x owl :members ( C1 … Cn ).
di s joi nt uni on Di s joi ntUni onOf(CN C1 … Cn) _Di s joi ntUni onOf(CN, ([C1,…, Cn ])
CN owl :di s joi ntUni onOf ( C1 … Cn ).
222
OntoBroker 6.3 Appendi x
equi va l ent Equi va l entObjectProperti es (P1 … Pn) _Equi va l entProperti es 1([P1 … Pn])
properti es
Pj owl :equi va l entProperty Pj+1. j=1…n-1
di s joi nt Di s joi ntObjectProperti es (P1 P2) _Di s joi ntProperti es (P1 P2)
properti es
P1 owl :propertyDi s joi ntWi th P2.
pa i rwi s e di s joi nt Di s joi ntObjectProperti es (P1 … Pn) _Di s joi ntProperti es 1([P1 … … Pn])
properti es
_:x rdf:type owl :Al l Di s joi ntProperti es .
_:x owl :members ( P1 … Pn ).
i nvers e Invers eObjectProperti es (P1 P2) owl #Thi ng[P1{i nvers eOf(P2)*=>()]
properti es
P1 owl :i nvers eOf P2.
i nvers e Invers eFuncti ona l ObjectProperty(P) owl #Thi ng[P{i nvers eFuncti ona l }*=>()]
functi ona l
P rdf:type owl :
property
Invers eFuncti ona l Property.
refl exi ve Refl exi veObjectProperty(P) Not s upported, s i nce not s upported i n
property OWL RL
P rdf:type owl :Refl exi veProperty.
i rrefl exi ve Irrefl exi veObjectProperty(P) owl #Thi ng [P {i rrefl exi ve} *=> ()].
property
P rdf:type owl :Irrefl exi veProperty.
223
OntoBroker 6.3 Appendi x
equi va l ent Equi va l entDa ta Properti es (R1 R2) _Equi va l entProperti es (R1,R2)
properti es
equi va l ent Equi va l entDa ta Properti es (R1 … Rn) _Equi va l entProperti es 1([R1 … Rn])
properti es
Rj owl :equi va l entProperty Rj+1. j=1…n-1
di s joi nt Di s joi ntDa ta Properti es (R1 R2) _Di s joi ntProperti es (R1 R2)
properti es
R1 owl :propertyDi s joi ntWi th R2.
pa i rwi s e di s joi nt Di s joi ntDa ta Properti es (R1 … Rn) _Di s joi ntProperti es 1([R1 … … Rn])
properti es
_:x rdf:type owl :Al l Di s joi ntProperti es .
_:x owl :members ( R1 … Rn ).
Datatype Definitions
224
OntoBroker 6.3 Appendi x
Assertions
nega ti ve object Nega ti veObjectPropertyAs s erti on(P a 1 _Nega ti vePropertyAs s erti on(P, a 1, a 2 )
property a2 )
a s s erti on
_:x rdf:type owl :
Nega ti vePropertyAs s erti on.
_:x owl :s ourceIndi vi dua l a 1.
_:x owl :a s s erti onProperty P.
_:x owl :ta rgetIndi vi dua l a 2.
nega ti ve da ta Nega ti veDa ta PropertyAs s erti on(R a v ) _Nega ti vePropertyAs s erti on(R, a , v )
property
_:x rdf:type owl :
a s s erti on
Nega ti vePropertyAs s erti on.
_:x owl :s ourceIndi vi dua l a .
_:x owl :a s s erti onProperty R.
_:x owl :ta rgetVa l ue v.
Keys
Key Ha s Key(C (P1 … Pm) (R1 … Rn) ) _Ha s Key(C, [P1,..,Pm, R1 … Rn] )
C owl :ha s Key (P1 … Pm R1 … Rn).
m+n>0
225
OntoBroker 6.3 Appendi x
Declarations
Run example
To s ta rt the exa mpl e del i vered by the OntoBroker i ns ta l l a ti on, run:
OntoBrokerHome> tools\benchmark.cmd benchmark\benchmark-throughput.xml
It ta kes s ome mi nutes for the benchma rk to fi ni s h. To s ee the report, open:
OntoBrokerHome\benchmark\outputDirectory_benchmark-throughput\benchmark-throughput.
html
226
OntoBroker 6.3 Appendi x
21.4 Built-ins
In thi s cha pter you fi nd a l l of the OntoBroker bui l t-i ns wi th thei r s ynta x, a s hort des cri pti on, thei r pa ra meters
a nd bi ndi ngs . In the Bi ndi ngs -col umn "b" mea ns tha t i t mus t be bound a nd "f" tha t the a rgument mus t be
free, us ua l l y a s a va ri a bl e.
You ca n get a compl ete l i s t of Bui l t-i ns i f you run the fol l owi ng query:
?- _builtins(?NAME,?ARITY,?DESCRIPTION,?PARAMETERS).
"_a bs Deci ma l " 2 a bs ol ute deci ma l va l ue ["i nput","a bs ol ute va l ue"] bf;fb;bb;
"_a cti veCol l a bora ti o 3 returns a cti ve col l a bora ti on ["modul e","us er","hos tna me"] fff;bff;fbf;
nUs ers " us ers a nd thei r hos tna me for bbf;ffb;bfb;
a modul e fbb;bbb;fff;
"_a cti veSes s i ons " 4 returns a cti ve s es s i ons ["s es s i oni d","type","us er","hos tn b;
a me"]
"_a dd" 3 a dds numbers us i ng doubl e ["s umma nd","s umma nd","s um"] bbf;bfb;fbb;
a ri thmeti c or dura ti ons to bbb;
da te/ti mes
"_a ddDeci ma l " 3 a dds numbers us i ng deci ma l ["s umma nd","s umma nd","s um"] bf;fb;bb;
a ri thmeti c
"_a ppl yStri ngTempl 4 a ppl i es s tri ng templ a te to the ["templ a te","opti ons ","va rBi ndi n bbbf;bbb;
a te" va ri a bl e bi ndi ngs gs ","output"]
227
OntoBroker 6.3 Appendi x
"_bui l ti ns " 4 Returns a l l a va i l a bl e bui l t-i ns ["na me","a ri ty","des cri pti on","l i s t
of pa ra meter na mes "]
"_cha rAt" 3 cha r a t pos i ti on ["s tri ng","pos i ti on","res ul t"] bbf;bbb;
"_computeexpl i ci t" 3 tra ns forma ti on pl ug-i ns for ["tra ns forma ti on","f(na me,
ma ppi ng tool va r)","res ul t"]
"_conca t" 3 conca tena te two s tri ngs ["fi rs t s tri ng","s econd
s tri ng","res ul t"]
bbf;bfb;fbb;
bbb;
"_cons tra i ntByID" 3 returns cons tra i nt text for ["modul e","cons tra i ntID","rul eTe bff;bbf;bfb;
gi ven ID xt"] gbb;
"_cons tra i ntConta i n 3 returns a i omxIDs for whi ch ["modul e","term","cons tra i ntID"]
s Term" the term i s conta i ned i n the
cons tra i nt formul a
bbf;bbb;
"_conta i ns " 2 fi rs t s tri ng/l i s t conta i ns ["s tri ng/l i s t","s tri ng/l i s t"] bb;
s econd s tri ng/l i s t
"_conta i ns N" 2 fi rs t s tri ng/l i s t conta i ns ["s tri ng/l i s t","s tri ng/l i s t"] bb;
s econd s tri ng/l i s t
"_currentDa teTi me" 1 returns the current da te ti me ["currentDa teti me"] f;b;
"_da ta type" 2 Gets the da ta type IRI of typed ["va l ue","da ta type"]
l i tera l s , xs d:s tri ng for untyped
l i tera l s , fa i l s otherwi s e.
"_di ffAt" 3 compa res two s tri ngs a nd ["content","i nput","pos i ti onOfFi rs
228
OntoBroker 6.3 Appendi x
"_di fference" 3 Crea tes di fference of two ["ma p1","ma p2","res ul t ma p"]
ma ps
"_ends Wi th" 2 fi rs t s tri ng/l i s t ends wi th ["s tri ng/l i s t","s tri ng/l i s t"]
s econd s tri ng/l i s t
bb;
"_fi l l " 4 fi l l Stri ng wi th n-ti mes of the ["ba s eStri ng","fi l l Stri ng","ti mes T
other s tri ng oFi l l ","res ul tStri ng"]
bbbf;bbbb;
bb;
"_fi rs tIndexOf" 3 returns fi rs t occura nce of the ["content","pa rt","l i s tOfPos i ti ons
s econd s tri ng/i tem wi thi n the "]
fi rs t s tri ng/l i s t
bbf;bbb;
"_fra cti ona l Second" 2 returns fra cti ona l s econd ["ti me/da teti me","fra cti ona l bf;bb;
s econd (deci ma l or nul l )"]
"_fra gment" 2 returns fra gment of IRI ["i ri ","fra gment s tri ng"]
bf;bb;
"_genera teExpl a na ti 4 genera tes expl a na ti on rul e ["modul e","rul eId","templ a te","o bbbf;bbbb;
onRul eText" text for gi ven rul eId a nd utput"]
templ a te
229
OntoBroker 6.3 Appendi x
"_grea terOrEqua l s " 2 grea ter tha n or equa l s ["l eft","ri ght"] bb;
compa ri s on (l eft >= ri ght)
"_grea terOrEqua l s N" 2 grea ter tha n or equa l s ["l eft","ri ght"] bb;
compa ri s on (l eft >= ri ght)
"_grea terTha n" 2 grea ter tha n compa ri s on (l eft ["l eft","ri ght"] bb;
> ri ght)
"_grea terTha nN" 2 grea ter tha n compa ri s on (l eft ["l eft","ri ght"]
> ri ght)
bb,
bf;bb;
bf;bb;
"_i ndexOf" 3 returns s orted l i s t of offs ets ["content","pa rt","l i s tOfPos i ti ons
from the s econd s tri ng wi thi n "]
the fi rs t
bbf;bbb;
"_i nteger2i ri " 3 converts between i nteger a nd ["i nteger","i ri prefi x","i ri "]
IRI
"_i nters ecti on" 3 Crea tes i nters ecti on of two ["ma p1","ma p2","res ul t ma p"]
ma ps
"_i s Cons tra i nt" 2 true i f gi ven i d i s a cons tra i nt ["modul e","cons tra i ntID"] bf;bb;
"_i s Cus tomPermi tte 2 checks i f current us er ha s ["modul e","cus tomPermi s s i on"]
d" cus tom permi s s i on for
modul e. Thi s i s onl y rel eva nt
230
OntoBroker 6.3 Appendi x
"_i s Modul ePermi tte 2 checks i f current us er ha s ["modul e","a cces s Ri ght"] bb;
d" a cces s ri ght for modul e. Thi s
i s onl y rel eva nt i s a cces s
control i s ena bl ed.
b;
bf;bb;
fb;bb;
bb;
"_l a ng" 2 Gets the l a ngua ge of a RDF ["l i tera l ","l a ngua ge"]
l i tera l , i f not a va i l a bl e i t
returns a n empty pl a i n l i tera l .
"_l a ngMa tches " 2 La ngua ge ra nge ma tchi ng a s ["l a ngua ge","fi l ter"]
defi ned i n RFC4647 s ecti on
3.3.1.
"_l a ngua ge" 2 Returns l a ngua ge pa rt of ["pl a i n l i tera l ","l a ngua ge"]
pl a i n l i tera l
bf;bb;
"_l a s tIndexOf" 3 returns l a s t occura nce of the ["content","pa rt","l i s tOfPos i ti ons bbf;bbb;
s econd s tri ng/i tem wi thi n the "]
fi rs t s tri ng/l i s t
"_l ength" 2 returns the l ength of a s tri ng ["s tri ng/l i s t","l ength"]
or l i s t
231
OntoBroker 6.3 Appendi x
bf;bb;
bb;
bb;
"_l es s Tha n" 2 l es s tha n compa ri s on (l eft < ["l eft","ri ght"]
ri ght)
bb;
"_l es s Tha nN" 2 l es s tha n compa ri s on (l eft < ["l eft","ri ght"]
ri ght)
bb;
"_l oca l Na me" 2 returns l oca l na me of IRI ["i ri ","l oca l na me"]
bf;bb;
"_l ogi nUs er" 2 returns l ogi n us er a nd ["us er","hos tna me"] ff;bf;fb;bb;ff;
hos tna me
232
OntoBroker 6.3 Appendi x
f;b;f;
bf;bb;
f;b;f;
bf;bb;
bbf;bfb;fbb;
bbb;
bbf;bfb;fbb;
bbb;
"_na mes pa ce" 2 returns na mes pa ce of IRI ["i ri ","na mes pa ce"]
bf;bb;
"_nega te" 2 nega tes a dura ti on ["dura ti on","dura ti on"] bf; fb; bb;
"_newIns ta nce" 5 crea tes a new i ns ta nce of the ["modul e","cl a s s na me","object"," bbbbf;
gi ven cl a s s na me a nd a s s i gns chi l dren","i ns ta nce"] bbbbb;
i ns ta nce reference
"_norma l i zeWi th" 3 Converts the yea rs a nd ["i nput (dura ti on)","reference bbf; bbb;
months fi el ds i nto the da ys poi nt (da te or da teti me)","res ul t
fi el d by us i ng a s peci fi c (dura ti on)"]
da teTi me/da te i ns ta nt a s the
233
OntoBroker 6.3 Appendi x
reference poi nt
"_overl a ppedBy" 3 True i f a s uffi x of the object ["s uffi xStri ng","prefi xs tri ng","num
s tri ng i s a l s o a prefi x of the berOfOverl a ppedCha rs "]
s tri ng gi ven i n the method's
a rgument. The res ul t of the bbf;bbb;
method i s the number of
cha ra cters i n the ma xi ma l
overl a p.
bf;bb;
"_prefi ces " 3 Returns prefi x/na mes pa ce ["modul e","prefi x","na mes pa ce"] bff;bbf;bfb;
defi ni ti ons per modul e bbb;
"_queryByID" 3 returns query text for gi ven ID ["modul e","queryID","rul eText"] bff;bbf;bfb;
bbb;
"_revers e" 2 revers es l i s t/s tri ng ["l i s t/s tri ng","revers ed l i s t/ bf;fb;bb;
s tri ng"]
ff;bf;fb;bb;ff;
bf;bb;
"_rul eByID" 3 returns rul e text for gi ven ID ["modul e","rul eID","rul eText"] bff;bbf;bfb;
bbb;
"_rul eConta i ns Term 4 returns rul eIDs for whi ch the ["modul e","term","i s Hea d","rul eI
234
OntoBroker 6.3 Appendi x
"_rul eID2Expl a na ti o 2 returns tra ns forms rul eID to/ ["rul eID","rul eExpl a na ti onRul eID
nRul eID" from rul eID of i ts expl a na ti on "]
rul e
"_s cheme" 2 returns s cheme of IRI ["i ri ","s cheme s tri ng"] bf;bb;
bf;bb;
bf;bb;
bf;bb;
"_s ta rts Wi th" 2 fi rs t s tri ng/l i s t s ta rts wi th ["s tri ng/l i s t","s tri ng/l i s t"]
s econd s tri ng/l i s t
bb;
"_s ta rts Wi thN" 2 fi rs t s tri ng/l i s t s ta rts wi th ["s tri ng/l i s t","s tri ng/l i s t"]
s econd s tri ng/l i s t
bb;
bf;
"_s ta tus Index" 2 provi des up-to-da te s ta tus for ["modul e","s ta tus text"]
i ndex
bf;bb;
"_s tr" 2 Returns the l exi ca l form of a ["va l ue","l exi ca l form"]
l i tera l or the codepoi nt
repres enta ti on of a n IRI.
bb;
235
OntoBroker 6.3 Appendi x
"_s ubs tri ng" 4 returns Stri ng.s ubs tri ng(s ta rt, ["content","s ta rt","end","s ubs tri n bbff;bbbf;
end) g"] bbfb;bbbb;
"_ti meInMi l l i s econd 2 returns ti me i n mi l l i s econds ["da teti me","mi l l i s econds s i nce
s" s i nce Ja nua ry 1, 1970 Ja nua ry 1, 1970 (Gregori a n),
(Gregori a n), mi dni ght UTC mi dni ght UTC"]
bf;
bf;bb;
bf;
"_toStri ng" 2 returns s tri ng repres enta ti on ["object","s tri ng repres enta ti on"]
bf;bb;
bbf;bbb;
"_toType" 4 returns new i ns ta nce for gi ven ["typena me","pa ra m1","pa ra m2", bbbb; bbbf;
pa ra meters "object"] bffb;bbfb;
bfbb
"_toType" 5 returns new i ns ta nce for gi ven ["typena me","pa ra m1","pa ra m2", bbff;bbbbf;
pa ra meters "pa ra m3","object"] bbbfb;
bbbbb;
"_toType" 7 returns new i ns ta nce for gi ven ["typena me","pa ra m1","pa ra m2",
pa ra meters "pa ra m3","pa ra m4","pa ra m5","ob
ject"]
bbbbbbf;
bbbbbbb;
"_toType" 8 returns new i ns ta nce for gi ven ["typena me","pa ra m1","pa ra m2", bbbbbbbf;
pa ra meters "pa ra m3","pa ra m4","pa ra m5","pa bbbbbbbb;
ra m6","object"]
"_toType" 9 returns new i ns ta nce for gi ven ["typena me","pa ra m1","pa ra m2", bbbbbbbbf;
pa ra meters "pa ra m3","pa ra m4","pa ra m5","pa bbbbbbbbb;
ra m6","pa ra m7","object"]
"_toType" 10 returns new i ns ta nce for gi ven ["typena me","pa ra m1","pa ra m2",
pa ra meters "pa ra m3","pa ra m4","pa ra m5","pa
ra m6","pa ra m7","pa ra m8","object
"] bbbbbbbbbf
;
bbbbbbbbb
b;
bf;bb;
"_tokeni ze" 3 Brea ks the object-s tri ng i nto a ["i nput s tri ng","del i m","token"]
236
OntoBroker 6.3 Appendi x
l i s t of tokens a t every
occurrence of a ny del i mi ter
bbf;bbb;
cha ra cter gi ven i n the
a rgument to the method (thi s
a rgument i s a s tri ng of
del i meter cha ra cters ). The
del i mi ter cha ra cters a re not
reta i ned a s pa rt of the
tokens . For i ns ta nce, 'xyzw.
foo'[_tokeni ze('y.') -> [x,zw,
foo]]
bbf;bbb;
"_tota l OrderLes s Tha 2 l es s tha n compa ri s on (l eft < ["l eft","ri ght"]
n" ri ght) provi di ng a tota l
orderi ng for a l l terms
bb;
"_tri m" 3 Del etes from the object s tri ng ["s tri ng","cha ra cters ","res ul t"]
a l l the l ea di ng a nd tra i l i ng
cha ra cters s peci fi ed i n the
a rgument to the method bbf;bbb
bf;bb;
bf;fb;bb;ff;
"_uni on" 3 Crea tes uni on of two ma ps ["ma p1","ma p2","res ul t ma p"]
bf;bb;
"_worki ngDa ys Betw 3 Ca l cul a tes the number of ["s ta rtDa te","endDa te","dura ti on bbf
een" worki ng da ys between two InDa ys "] (ca l cul a te
da tes . Publ i c hol i da ys a re not da ys )
cons i dered.
bfb
(ca l cul a te
end da te)
bbb
(va l i da te)
fbb
(ca l cul a te
s ta rt da te)
237
OntoBroker 6.3 Appendi x
b;
b;b;
b;b;b;
b;b;b;b;
b;b;b;b;b;
bf;bb;
"_zoneHour" 2 returns zone hour (wi th s i gn) ["ti me/da teti me","zone hour"] bf;bb;
"_zoneMi nute" 2 returns zone mi nute (wi th ["ti me/da teti me","zone mi nute"]
s i gn)
bf;bb;
238
OntoBroker 6.3 Appendi x
The <opti on l i s t> pa ra meter cons i s ts of a l i s t of opti ona l pa ra meter. If no opti ona l pa ra meters s houl d be
s peci fi ed, us e the empty l i s t, i .e. []
Parameter Description
return(<field>) The content of the fi el d i s returned for the hi t i n the <opti ona l output l i s t> va ri a bl e.
Note tha t the fi el d mus t be defi ned a s “s tored” i n the Lucene i ndex, otherwi s e
nothi ng i s returned.
The content of the fi el d i s returned for the hi t i n the <opti ona l output l i s t> va ri a bl e.
Note tha t the fi el d mus t be defi ned a s “s tored” i n the Lucene i ndex, otherwi s e
nothi ng i s returned.
Exa mpl e:
?- _queryIndex(module1, [return("name_en")], "name_en:foo", 0,
10, ?Obj, ?Tc, ?Sc, ?Order, ?Opt).
For every “na me_en” fi el d of a hi t document i n the Lucene i ndex, the <opti ona l
output l i s t> wi l l conta i n a n i tem na me_en("content of fi el d")
stringmetric(<metric>)
Sets the s tri ng metri c to be us ed for the fuzzy s ea rch. If thi s opti on i s not s et, the
defa ul t va l ue i s us ed, ei ther expl i ci tl y s peci fi ed by the property
“defa ul tStri ngMetri c” i n the ful l texti ndex-confi g.xml or i f thi s i s a l s o not s et, the
s tri ng metri c “Ja ro” i s us ed.
Supported s tri ng metri c va l ues a re:
"Levens tei n", "MongeEl ka n", "Needl ema nWunch", "QGra ms ", "Ja ro",
"Ja roSca l ed", "Ja roWi nkl er", "Da mera uLevens htei n", "Da mera uLevens htei nSca l ed",
"Ma xJa roDa mera uLevens htei nSca l ed", "Da mera uLevens htei nSoundex", "Ja cca rd",
"Soundex", "Smi thWa terma n"
Si de rema rk:
You ca n us e the bui l t-i n di s ta nce2 to s ee how two s tri ngs compa re us i ng one of
thes e s tri ng metri cs , e.g.
?- _distance2("Jaro", "good", "food", 0, ?X).
239
OntoBroker 6.3 Appendi x
includeall Incl udes a l l i mported modul es of <modul e> (fi rs t a rgument) i n the s ea rch.
Exa mpl e:
?- _queryIndex(module1, [includeAll], "foo", 0, 10, ?Obj, ?Tc, ?
Sc, ?Order, ?Opt).
defaultfield Sets the defa ul t fi el d to be us ed for s ea rch terms whos e fi el d i s not expl i ci tl y gi ven.
(<field>) E.g. i f you ha ve the Lucene query text "a l l :foo ba r", the s ea rch term "foo" i s s ea rched
i n the fi el d "a l l " a nd ba r i s s ea rched i n the defa ul t fi el d.
If the defa ul t fi el d i s not s et i n the opti on, the defa ul t fi el d s peci fi ed i n the
ful l texti ndex-s chema .xml (ta g defa ul tSea rchFi el d) i s us ed. If thi s i s a l s o not s et, the
defa ul t fi el d i s "a l l ".
Exa mpl e:
?- _queryIndex(module1, [defaultfield("name_en")], "foo", 0,
10, ?Obj, ?Tc, ?Sc, ?Order, ?Opt).
Us e fi el d "na me_en" a s defa ul t fi el d
solrparam(<name>, Sets a ddi ti ona l Apa che Sol r pa ra meters . The queryIndex bui l t-i n us es a l s o the core
<value>) of Apa che Sol r on top of Lucene. Wi th thi s opti on you ca n s et one or mul ti pl e
pa ra meters for thi s l a yer.
Exa mpl e:
?- _queryIndex(module1, [solrparam("hl", "true"), solrparam("hl.
fl","name_en"),
solrparam("hl.snippets", "2"),
solrparam("hl.fragsize", "200")")], "foo", 0, 10, ?Obj, ?Tc, ?Sc,
?Order, ?Opt).
Thes e pa ra meters ena bl e the Sol r hi ghl i ghti ng. Pl ea s e note tha t onl y s tored fi el ds
ca n be us ed for hi ghl i ghti ng. More deta i l s a bout the Sol r pa ra meter for hi ghl i ghti ng
ca n be found here:
http://wi ki .a pa che.org/s ol r/Hi ghl i ghti ngPa ra meters
externalindexeson If thi s opti on i s s et, the modul e i n the fi rs t a rgument i s i gnored. Note tha t i n thi s
ly ca s e the opti on externa l i ndex(<pa th>) mus t be s et.
externalindex Adds one or mul ti pl e externa l Lucene i ndexes for the s ea rch. Note tha t the us ed
(<path>) fi el ds mus t nonethel es s be defi ned i n the ful l texti ndex-confi g.xml .
Exa mpl e:
?- _queryIndex(dummy, [externalindexesonly, externalindex("d:/
index1"),externalindex("d:/index2")], "foo", 0, 10, ?Obj, ?Tc, ?
Sc, ?Order, ?Opt).
Incl udes the Lucene i ndexes l oca ted i n the di rectory d:\i ndex1 a nd d:\i ndex2
You ca n us e the Sol r query s ynta x extens i ons i n the <Lucene query text> a rgument. Thi s a l l ows us i ng
cus tomi zed query pa rs ers to a dd new functi ona l i ty to the s ea rch. A cus tomi zed query pa rs er i s s peci fi ed by
s ta rti ng the query text wi th “{!pa rs erna me pa ra m1=va l ue1 pa ra m2=va l ue2}”. Here pa rs erna me i s the na me of
the query pa rs er, pa ra m1, va l ue1, pa ra m2, va l ue2 a re s a mpl e pa ra meter/va l ue pa i rs .
OntoBroker currentl y s upports two extended query pa rs ers : l ucene a nd mul ti fi el d
240
OntoBroker 6.3 Appendi x
lucene
Thi s i s a norma l Lucene query whi ch s ome a ddi ti ona l pa ra meters s peci fi ed di rectl y i n the query text.
Parameter Description
q.op Defa ul t opera tor (ei ther AND or OR). The s ta nda rd defa ul t
opera tor i s AND
df Defa ul t fi el d (s ee a bove)
Exa mpl e:
?- _queryIndex(module1, [], "{!lucene df=name_en q.op=OR sort='id asc'} foo bar", 0,
10, ?Obj, ?Tc, ?Sc, ?Order, ?Opt).
Queri es for "foo OR ba r" i n the defa ul t fi el d "na me_en" a nd s orti ng the res ul ts a s cendi ng by the fi el d i d.
multifield
Thi s query pa rs er s ea rches for the s ea rch terms i n mul ti pl e defa ul t fi el ds . It s upports the s a me pa ra meters
a s the l ucene query pa rs er pl us a ddi ti ona l l y:
Parameter Description
fi el ds Fi el ds to s ea rch, e.g. fi el ds ='na me_en^2 docu_en'. Here a
hi t i n the fi el d na me_en i s boos ted a ddi ti ona l l y by a
fa ctor 2
Exa mpl e:
?- _queryIndex(module1, [return(name_en),return(docu_en)], "{!multifield
fields='name_en docu_en' q.op=OR sort='id asc'} foo bar", 0, 10, ?Obj, ?Tc, ?Sc, ?
Order, ?Opt).
Queri es for "foo OR ba r" i n the fi el ds "na me_en" a nd "docu_en" a nd s orti ng the res ul ts a s cendi ng by the fi el d
i d a nd returns fi el ds "na me_en" a nd "docu_en".
241
OntoBroker 6.3 Appendi x
id yes yes Thi s fi el d s tores the untokeni zed ObjectLogi c term repres enta ti on
(untokeni of the object.
zed)
lid yes yes Fi el d for i ndexi ng the l oca l na me of the ObjectLogi c object term (for
terms whi ch a re not IRI thi s i s the s a me a s the i d)
repr_de yes yes Conta i ns the l a ngua ge-dependent l a bel for a gi ven object
repr_en
na me_de yes yes Thi s fi el d conta i ns the l a bel a nd the s ynonyms i n the gi ven
l a ngua ge. By defa ul t the i ndexer onl y crea tes fi el ds for the
na me_en
l a ngua ges “de” a nd “en”.
...
If thi s fi el d i s returned (e.g. <opti on l i s t> = […,return(na me_en),…]),
the fi rs t l i ne a l wa ys conta i ns the l a bel .
all no yes Conta i ns a l l text of the fi el ds l i d, na me_{l a ng}, docu_{l a ng}, a ttva l ,
s yn
a xi omtext yes yes Conta i ns the rul e text for rul es , queri es a nd cons tra i nts .
Al l fi el ds whi ch a re i ndexed ca n be us ed i n the query text. For a l l fi el ds whi ch a re s tored a “return” opti on
ca n be s peci fi ed.
Exa mpl e:
?- _queryIndex(<http://company.com#onto1>,
[return(name_en),return(type),includeall], "+name_en:city
+type:i +assertedisa:\"<http://company.com#Region>\"", 0, 20,
?OBJ,?TC,?SCORE,?ORDER,?OPT).
Thi s query s ea rches for i ns ta nces of <http://company.com#Region> i n the modul e <http://company.
com#onto1> whos e Engl i s h repres enta ti on or s ynonym conta i ns the word “ci ty”.
Here a re s ome more exa mpl es for va l i d Lucene query text:
242
OntoBroker 6.3 Appendi x
ci ty s a me a s “a l l :ci ty”
+na me_en:vi l l a ge +type:i s ea rches for i ns ta nces whos e Engl i s h repres enta ti on or s ynonym conta i ns
the word “vi l l a ge”
i d:"http://compa ny. Sea rches for the object wi th the i d <http://compa ny.com#Project>
com#Project"
21.4.2.1 Comparisons
243
OntoBroker 6.3 Appendi x
- 1 _number b Mul ti pl i es -2
a rgument 1 by -1
a nd returns the
res ul t.
244
OntoBroker 6.3 Appendi x
245
OntoBroker 6.3 Appendi x
or _i nteger va l ue
tha t i s not
s ma l l er tha n the
va l ue i n
a rgument 1.
_i nteger i s
returned i f the
a rgument i s
_i nteger or
_deci ma l .
Otherwi s e, _l ong
i s returned.
246
OntoBroker 6.3 Appendi x
pos i ti ve s qua re
root of a
pos i ti ve
number.
Basic syntax
The ori gi na l F-l ogi c di s ti ngui s hed between functi ona l a nd s et-va l ued a ttri butes a nd methods . In thi s forum
we deci ded to a ba ndon thi s di s ti ncti on a nd repl a ce i t wi th a more genera l mecha ni s m of ca rdi na l i ty
cons tra i nts . We wi l l us e onl y s et-va l ued a ttri butes a nd el i mi na te the doubl e-a rrows —>> a nd =>>. The a rrows
-> a nd => wi l l be us ed for everythi ng. The functi ona l property of the a ttri butes wi l l be expres s ed us i ng
ca rdi na l i ty cons tra i nts . Ins tea d of us i ng ; to s epa ra te the di fferent pa rts i n a n F-l ogi c mol ecul e, us e the
comma or a nd. The s emi col on or or wi l l be us ed for di s juncti ons i n the rul e body.
OWL-like properties
The a bove s ynta x wi l l be extended to a l s o a ccommoda te OWL-l i ke properti es of F-l ogi c a ttri butes : s ymmetri c
a nd i nvers eOf(Attr). For i ns ta nce:
Person[marriedTo{1:1,symmetric}=>Person], Person[childOf{0:2,inverseOf(parent)}=>
Person]
Unl i ke the ca rdi na l i ty s peci fi ca ti on, s ymmetri c a nd i nvers eOf(...) a re not cons tra i nts . Ins tea d, they a re trea ted
a s a s hortcut tha t a voi ds the need to s peci fy a rul e expl i ci tl y. For i ns ta nce:
?P1[marriedTo -> ?P2] :- ?P2:Person[marriedTo -> ?P1:Person].
General constraints
For more genera l cons tra i nts , we wi l l us e the s ynta x
!- constraintBody
ra ther tha n ?- cons tra i ntBody. It wi l l be up to the i mpl ementa ti on to deci de when cons tra i nts a re i nvoked:
when the fi l e i s l oa ded or when a n upda te occurs . A cons tra i nt wi l l be s a i d to be vi ol a ted i f pos i ng
cons tra i ntBody a s a query yi el ds a s ol uti on.
247
OntoBroker 6.3 Appendi x
Upperca s i ng (a s i n Prol og) wi l l not be us ed, s o upperca s e i denti fi ers wi l l be permi tted wi thout the
quotes . The na me of a va ri a bl e ca n be a ny s equence of a l pha numeri c s ymbol s pl us the unders core _.
The va ri a bl e i s a nonymous . As i n Prol og, ea ch denote a uni que new va ri a bl e tha t does not occur
a nywhere el s e.
b) Expl i ci t qua nti fi ca ti on
Expl i ci t qua nti fi ca ti on i n the rul e body i s a l l owed to s upport the Ll oyd-Topor extens i ons . Both uni vers a l
(fora l l ) a nd exi s tenti a l (exi s t) qua nti fi ca ti on i s permi tted.
c) Impl i ci t qua nti fi ca ti on
Al l va ri a bl es tha t a re not qua nti fi ed expl i ci tl y a re a s s umed to be qua nti fi ed i mpl i ci tl y outs i de of the
rul e wi th the fora l l qua nti fi er. No expl i ci t uni vers a l qua nti fi er for the whol e rul e wi l l be needed a nd wi l l
not be s upported.
d) If-then
Al l ow the i f-then-el s e s ynta x a s wel l a s the a <--b a nd a -->b a l terna ti ves for i f-then.
Id i s a cons ta nt, whi ch repres ents the rul e/query/cons tra i nt l a bel . It s houl d be uni que wi thi n the rul e s et.
The fra mes i n the conjuncti on a re i ntended to repres ent meta da ta a s s oci a ted wi th the rul e/query/cons tra i nt
to whi ch the a nnota ti on i s a tta ched.
There i s a predefi ned meta da ta object opti ons [...] to control the executi on a nd output beha vi our of a query. It
ca n conta i n fol l owi ng opti ons (s peci fi ed a s Bool ea n methods ):
Exa mpl es :
@{rule12}
bar :- foo.
@{options[outorder(?Y)]}
?- ?X[?Y->?Z].
@{query13,
query13[author->Martin],
options[sort(asc(?X),desc(?Y)),outorder(?X,?Y),maxnumber(1)]}
?- ?X[name->?Y].
248
OntoBroker 6.3 Appendi x
Structural inheritance
We wi l l us e *=> for i nheri ta bl e types a nd => for the non-i nheri ta bl e ones wi th the fol l owi ng i nference rul es :
C2::C1, C1[M *=> T] |= C2[M *=> T]
O::C, C[M *=> T] |= O[M => T]
For da ta -mol ecul es , both -> a nd *-> a re a l l owed. In the ba s i c ca s e, they wi l l ha ve the s a me s ema nti cs , except
tha t => wi l l s peci fy the type for -> a nd *=> the type for *->.
Aggregates
Thi s forum a dopted the s ynta x for a ggrega tes propos ed i n FLORA-2:
?Var = count{?Var [GroupingVarList] | Query}
?Var = sum{?Var [GroupingVarList] | Query}
?Var = avg{?Var [GroupingVarList] | Query}
?Var = max{?Var [GroupingVarList] | Query}
?Var = min{?Var [GroupingVarList] | Query}
?Var = collectset{?Var [GroupingVarList] | Query}
?Var = collectbag{?Var [GroupingVarList] | Query}
Modules
Modul es a re des cri bed i n a s epa ra te document.
Anonymous resources
Wi l l a dopt the FLORA-2 s ema nti cs a nd s ynta x for a nonymous oi ds . Thi s ha s a l s o been a dopted by WSML a nd
SWSL. Accordi ng to thi s propos a l , _# mea ns a compl etel y new i denti fi er (ea ch occurrence) a nd numbered
vers i ons _#1, _#2, ... mea n compl etel y new i denti fi ers except tha t wi thi n the s a me cl a us e di fferent
occurrences of the s a me a nonymous oi d (e.g., _#2) denote the s a me i denti fi er.
Data types
Da ta types wi l l be repres ented a s terms , not s tri ngs . A compl ete l i s t of ba s e da ta types i s found i n a s epa ra te
document. 250
249
OntoBroker 6.3 Appendi x
250
OntoBroker 6.3 Appendi x
_dateTime
Cl a s s _da teTi me
Cl a s s methods _da teTi me[_toType(_i nteger,_i nteger,_i nteger,_i nteger,_i nteger,_i nteger,_deci ma l ,
_i nteger,_i nteger,_i nteger) => _da teTi me]
_da teTi me[_toType(_i nteger,_i nteger,_i nteger,_i nteger,_i nteger,_deci ma l ,_i nteger,
_i nteger) => _da teTi me]
The mea ni ng of the a rguments i s a s fol l ows (i n tha t order): da te s i gn, yea r, month,
da y, hour, mi nute, s econd, zone s i gn,, zone hour, zone mi nute.
Al l a rguments , except da te s i gn a nd zone s i gn, a re a s s umed to be pos i ti ve i ntegers ,
whi l e da te s i gn a nd zone s i gn ca n be ei ther 1 or -1. For nega ti ve ti me zones both
va l ues ha ve to be nega ti ve, for da tes the s a me. Da te s i gn a nd zone s i gn a re not
a va i l a bl e.
_da teTi me[_toType(_s tri ng) => _da teTi me]
_da teTi me[=> _i s TypeOf(_object)] Tel l s i f object bel ongs to the pri mi ti ve type
_da teTi me
251
OntoBroker 6.3 Appendi x
_date
Expl a na ti on XML Schema da te type
Cl a s s _da te
Cl a s s methods _da te[_toType(_i nteger,_i nteger,_i nteger,_i nteger,_i nteger,_i nteger,_i nteger) =>
_da te]
_da te[_toType(_i nteger,_i nteger,_i nteger,_i nteger,_i nteger) => _da te]
The mea ni ng of the a rguments i s a s fol l ows (i n tha t order): da te s i gn, yea r, month,
da y, zone s i gn, zone hour, zone mi nute.
Al l a rguments , except da te s i gn a nd zone s i gn, a re a s s umed to be pos i ti ve i ntegers ,
whi l e da te s i gn a nd zone s i gn ca n be ei ther 1 or -1. For nega ti ve ti me zones both
va l ues ha ve to be nega ti ve, for da tes the s a me. Da te s i gn a nd zone s i gn a re not
a va i l a bl e.
_da te[_toType(_s tri ng) => _da te]
_da te[=> _i s TypeOf(_object)] Tel l s i f object bel ongs to the pri mi ti ve type _da te
252
OntoBroker 6.3 Appendi x
_time
Expl a na ti on XML Schema ti me da ta type
Cl a s s _ti me
Cl a s s methods _ti me[_toType(_i nteger,_i nteger,_deci ma l ,_i nteger,_i nteger,_i nteger) => _ti me]
_ti me[_toType(_i nteger,_i nteger,_deci ma l ,_i nteger,_i nteger) => _ti me]
The a rguments repres ent hour, mi nute, s econd, ti me zone s i gn, ti me zone hour, a nd
ti me zone mi nute.
_ti me[_toType(_s tri ng) => _ti me]
_ti me[=> _i s TypeOf(_object)] Tel l s i f object bel ongs to the pri mi ti ve type _ti me
253
OntoBroker 6.3 Appendi x
_duration
Expl a na ti on XML Schema dura ti on type
Cl a s s _dura ti on
Cl a s s methods _dura ti on[_toType(_i nteger,_i nteger,_i nteger,_i nteger,_i nteger,_i nteger) =>
_dura ti on] The mea ni ng of the a rguments (i n tha t order) i s : yea r, month, da y, hour,
mi nute, s econd.
_dura ti on[_toType(_s tri ng) => _dura ti on]
_dura ti on[=> _i s TypeOf(_object)] Tel l s i f object bel ongs to the pri mi ti ve type
_dura ti on
254
OntoBroker 6.3 Appendi x
_boolean
Expl a na ti on XML Schema Bool ea n type
Cl a s s _bool ea n
Note:
_fa l s e[_l es s Tha n(_true)])
_bool ea n[_typeNa me *=> _s tri ng]
_double
Expl a na ti on XML Schema doubl e type
Cl a s s _doubl e
255
OntoBroker 6.3 Appendi x
_decimal
Expl a na ti on XML Schema deci ma l type (a rbi tra ry preci s i on)
Cl a s s _deci ma l
Cl a s s methods _deci ma l [_toType(_s tri ng) => _deci ma l ] Converts s tri ng to deci ma l , i f s tri ng
repres ents a deci ma l i n textua l form. If i t does not, then the method fa i l s .
_deci ma l [_toType(_doubl e) => _deci ma l ] Converts doubl es to deci ma l s .
_deci ma l [=> _i s TypeOf(_object)]
_integer
Expl a na ti on XML Schema i ntegers (a rbi tra ry l ength)
Note:
Al though XML s chema pres cri bes tha t _i nteger mus t be a s upertype of _l ong, we do
not enforce thi s rul e due to the di ffi cul ty i n i mpl ementi ng i t. However, the _equa l s
method i s s uppos ed to recogni ce tha t _l ong i s a s ubtype of _i nteger, i .e., "18"^^_l ong
[_equa l s ("18"^^_i nt)] mus t be true a nd s o mus t be "18"^^_i nt[_equa l s ("18"^^_l ong)].
Cl a s s _i nteger
Cl a s s methods _i nteger[_toType(_s tri ng) => _i nteger] Converts s tri ngs to i ntegers , i f the s tri ng
repres ents a n i nteger i n textua l form. If i t does not then thi s method fa i l s .
_i nteger[_toType(_l ong) => _i nteger] Converts l ong to i ntegers .
_i nteger[=> _i s TypeOf(_object)]
Component
methods
256
OntoBroker 6.3 Appendi x
_long
Expl a na ti on XML Schema l ong i ntegers
Cl a s s _l ong
Cl a s s methods _l ong[_toType(_s tri ng) => _l ong] Converts s tri ngs to l ong i ntegers , i f the s tri ng
repres ents a n i nteger i n textua l form. If i t does not then thi s method fa i l s .
_l ong[_toType(_i nteger) => _l ong] Converts l ong i ntegers to a rbi tra ry bi g i ntegers .
_i nteger[=> _i s TypeOf(_object)]
Component
methods
257
OntoBroker 6.3 Appendi x
_iri
Expl a na ti on IRI a s defi ned by [RFC 2396], a s a mended by [RFC 2732]
Cl a s s _i ri
Note:
The exa ct mea ni ng of the a bove components depends on the IRI s cheme. For http, ftp,
fi l e, etc., the mea ni ng the fi rs t fi ve components i s cl ea r. The query i s a n opti ona l pa rt
of the IRI tha t fol l ows the ?-s i gn, a nd fra gment i s the l a s t pa rt tha t fol l ows #. Some
components mi ght be opti ona l for s ome IRI s chemes . For i ns ta nce, for the urn a nd fi l e
s chema ta , onl y the pa th component i s defi ned. For ma i l to s cheme, port, pa th, query,
a nd fra gment a re not defi ned. If a s cheme i s not recogni zed then the pa rt of the IRI
tha t fol l ows the s cheme goes i nto the pa th component unpa rs ed.
_iri[_localName *=> _string]
_iri[_namespace *=> _string]
Thes e two a ttri butes return the l oca l na me a nd prefi x of the IRI a s defi ned by RDF
bes t pra cti ces . **** Defi ne l oca l na mes ! **** The prefi x i s the pa rt of the IRI tha t
precedes the l oca l na me.
_string
Expl a na ti on XML Schema s tri ng type
Cha ra cters ca n be Uni code cha ra cters , excl udi ng the s urroga te bl ocks FFFE a nd FFFF.
258
OntoBroker 6.3 Appendi x
Cl a s s _s tri ng
259
OntoBroker 6.3 Appendi x
_PlainLiteral
Expl a na ti on XML Schema s tri ng type wi th a ddi ti ona l l a ngua ge ta g. NOTE: thi s da ta type i s currentl y
under di s cus s i on a t W3C, s o the s peci fi cs mi ght cha nge.
Thi s i s l i ke _s tri ng, but the s a me s tri ng wi th di fferent l a ngua ge ta gs a re cons i dered
di fferent. _text i s a s ubtype of _s tri ng, s o a l l of the methods of _s tri ng a re a ppl i ca bl e to
_text. We don't s upport thi s s ubtype property, beca us e we coul d not deci de wha t type
to genera te a s res ul t. If needed, _text ha s to be converted to s tri ng expl i ci tl y. The
l a ngua ge ta g ca n be a l s o ISO-639-1 (or ISO-639-2) to s peci fy encodi ngs .
Cl a s s _text
260
OntoBroker 6.3 Appendi x
_list
Expl a na ti on The Prol og type of l i s t.
Cl a s s _l i s t
261
OntoBroker 6.3 Appendi x
_XMLLiteral
Expl a na ti on XMLLi tera l type of RDF.
An XML l i tera l i s a s tri ng tha t conta i ns a wel l -formed fra gment of XML text. _XMLLi tera l
i s a s ubtype of _s tri ng, s o a l l of the methods of _s tri ng a re a ppl i ca bl e to _text. We don't
s upport thi s s ubtype property, beca us e we coul d not deci de wha t type to genera te a s
res ul t. If needed, _XMLLi tera l ha s to be converted to s tri ng expl i ci tl y.
Cl a s s _XMLLi tera l
Component
methods
21.4.4.2 Miscellaneous
a p da ta typ
Ma ppi ng between Ja va objects a nd ObjectLogi c
Exa mpl e:
BLZ Servi ce of the Deuts che Bundes ba nk, s ee
http://www.thoma s -ba yer.com/a xi s 2/s ervi ces /BLZServi ce?ws dl
Genera ti ng the Ja va cl i ent for thi s web s ervi ce res ul ts i n (s i mpl i fi ed here):
Ja va
interface BLZService {
Details getDetails(String blz);
}
class Details {
String bezeichnung;
String bic;
String ort;
String plz;
}
Interna l l y the i nput pa ra meters , here the s i ngl e pa ra meter “bl z” i s extra cted from the i nput ma p a nd the web
s ervi ce i s ca l l ed vi a the genera ted Ja va cl i ent. The res ul t i s returned i n a Deta i l s object. Thi s object i s
ma pped i nto a ma p cons ta nt term:
?Result = [bezeichnung->"Postbank Karlsruhe",
bic->"PBNKDEFF",ort->"Karlsruhe",plz->"76127"]
262
OntoBroker 6.3 Appendi x
Exa mpl e:
XML
<animals>
<dog id="1">
<name>Rufus</name>
<breed>labrador</breed>
</dog>
<dog id="2">
<name>Marty</name>
<breed>whippet</breed>
</dog>
<cat name="Matilda"/>
</animals>
ObjectLogi c
?X = [animals->[
[dog->[
[id->1,name->"Rufus",breed->"labrador"],
[id->2,name->"Marty",breed->"whippet"]
],
cat->[
[name->"Matilda"]
]
]
]
For the a bove exa mpl e, the ?OPT va ri a bl e currentl y returns thi ngs l i ke
?OPT = [type("c"),title("Reparaturanleitung")]
Us i ng the ma p da ta type, thi s woul d be i ns tea d
?OPT = [type->"c",title->"Reparaturanleitung"]
Speci fi ca ti on Deta i l s
The s ynta x i s jus t a n overl oa di ng of the l i s t s ynta x. The s qua re bra ckets woul d conta i n key/va l ue pa i rs
i ns tea d of terms . Mi xi ng terms a nd key/va l ue pa i rs i s forbi dden, a l s o the hea d/ta i l s ynta x us ed for l i s ts .
Assignments
?X=[1,2,3] list
263
OntoBroker 6.3 Appendi x
?X=[1|?Y] Li s t hea d / ta i l
?X=[a ->1,b->2] Ma p
Facts
?- ?M = col l ectma p { ?X,?Y | r(?X,?Y) }. Aggrega ti on col l ectma p to col l ect key/va l ue
pa i rs i n one ma p
tra ns l a tes i nto:
?- _a ggr_col l ectma p([],[?X,?Y], ?X, ?Y, ?M), r(?X,?Y)).
?- [a ->{1,2},b->3,c->4][_i nters ecti on([a ->1, c->5])->?X]. Bui l t-i n _i nters ecti on/3 to crea te
i nters ecti on of two ma ps
returns :
?X = [a ->1]
?- [a ->{1,2},b->3,c->4][_uni on([a ->1, c->5])->?X]. Bui l t-i n _uni on/3 to crea te uni on of two
ma ps
returns :
?X = [a ->{1,2},b->3,c->{4,5}]
?- [a ->{1,2},b->3,c->4] [_di fference([a ->1, c->5])->?X]. Bui l t-i n _di fference/2 to remove a l l key/
va l ue pa i rs of a rgument1 from a rgurment 0
returns :
?X = [a ->2,b->3,c->4]
returns :
?X = [a ->{2,4}, b->1]
264
OntoBroker 6.3 Appendi x
returns :
?X = [a ->2]
?- ?M = [a ->[b->[1,2], c->3], d->4],_memberByPa th(?M,_pa th(a , Bui l t-i n _memberByPa th/3 to fi l ter wi th
b),?V). xpa th expres s i on
returns
?V = [1,2]
?- ?M = [a ->[b->[1,2], c->3], d->4], _ma p2ta bl e(?M,?P,?I,?V). Bui l t-i n _ma p2ta bl e/4 to convert a ma p to
fl a t ta bl e. Note tha t l i s t va l ues a re
converted to fl a t ta bl e too.
returns
P I V
---------------
"a .b" 0 1
"a .b" 1 2
"a .c" 0 3
"d" 0 4
returns
P I V
---------------
"a .b" 0 1
"a .b" 1 2
"a .c" 0 3
"d" 0 4
returns :
true
res ul ts i n:
?M = [name->"Jürgen", age->28]
265
OntoBroker 6.3 Appendi x
res ul ts i n:
?M = [name->"Jürgen", age->28,
address->[street->"An der RaumFabrik", ort->"Durlach"]].
21.4.4.3 Implementation
Ma ps a re s tored a s functi ons i nterna l l y. The functi on s ymbol i s $m a nd the a rguments a re a s equence of key
va l ue pa i rs . Thi s i mpl i es tha t the key va l ue pa i rs a re ordered a nd tha t a key ca n ha ve mul ti pl e va l ues .
Therefore [a ->b,c->d] does not uni fy wi th [c->d,a ->b]. If you need to uni fy ma ps , us e the norma l i ze bui l t-i n to
bri ng the key/va l ue pa i rs i n a the s a me order.
[a ->{1,2,3},b->[1,2]] Mul ti -va l ued ma p. Note the di fference $m(a ,1,a ,2,a ,3,b,$l (1,$l (2,[])))
between the va l ues for a a nd b. a i s mul ti -
va l ued, but b ha s a l i s t a s va l ue.
from the copyri ght of the web pa ge http://forum.projects .s emwebcentra l .org/forum-s ynta x.html
21.5 Aggregations
You ca n get a compl ete l i s t of a ggrega ti ons i f you run the fol l owi ng query:
?- _aggregations(?NAME,?ARITY,?DESCRIPTION,?PARAMETERS).
266
OntoBroker 6.3 Appendi x
col l ectPropertyEntri e 3 col l ects property entri es for l a ter i ns erti on ["property","va l ue","order"]
s i n ja va cl a s s
dynSvcBui l dTree 5 col l ects property entri es for l a ter i ns erti on ["cl s ","i d","property","va l ue","o
i n ja va cl a s s rder"]
21.6 Connectors
You ca n get a compl ete l i s t of connectors i f you run the fol l owi ng query:
?- _connectors(?NAME,?ARITY,?DESCRIPTION,?PARAMETERS).
_queryIndex 10 queri es ful l -text i ndex for ontol ogy of ["modul e","opti ons ","query
gi ven modul e s tri ng","s ta rt","ba tch","object",
"tota l
count","s core","order","opti ona
l "]
s pa rql a cces s i nterna l 5 executes s pa rql queri es ["a ddres s ","l i s t of defa ul t
gra phs ","l i s t of na med
gra phs ","s pa rql query","ma p
267
OntoBroker 6.3 Appendi x
wi th res ul t"]
_s pa rql queryi nterna l 6 executes s pa rql queri es ["a ddres s ","l i s t of defa ul t
gra phs ","l i s t of na med
gra phs ","s pa rql query","ma p
wi th res ul t","va ri a bl es for
tupl e ca che"]
_webs ervi ceInfo 4 Retri eves i nforma ti on for web s ervi ce ["i nput
ma p","s ervi ce","method","met
hod i nfo ma p"]
Eva l ua ti onMethod choos e, Dyna mi cFi l teri ng, Dyna mi cFi l teri ng2, choos e
BottomUp, Di s juncti veMa gi cSet
Extens i ons .Di rectory To s peci fy mul ti pl e extens i ons di rectory jus t us e the -
OntoConfi g pa ra meter
Extens i ons .Di rectory a s us ua l a nd s epa ra te the
di rectori es by comma .
268
OntoBroker 6.3 Appendi x
-bui l ti nDi r <di rectory na me> di rectory where bui l t-i ns a re l oca ted
-X:i ndexArguments <predi ca teNa me>'/'<predi ca teAri ty> i ndexes a l l a rguments of the
s peci fi ed predi ca te
-X:i ndexAl l <predi ca teNa me>'/'<predi ca teAri ty> i ndexes a l l pos s i bl e pos i ti ons of the
s peci fi ed predi ca te
-rdf, -rdfs ,-owl , -nt, -nt3, <di rectory na me > or <fi l e na me> s peci fi es the l oa ded fi l es /di rectory
-obl a ccordi ng to the us ed da ta forma t
270
OntoBroker 6.3 Appendi x
271
OntoBroker 6.3 Appendi x
272
OntoBroker 6.3 Appendi x
Ses s i on.Ti meOut Speci fi es the ti meout for a n OntoBroker Ses s i on.Ti meOut = 1800000
s es s i on i n mi l l i s econds .
273
OntoBroker 6.3 Appendi x
The i ndexer ca n now be cus tomi zed wi th a ddi ti ona l fi el ds . Va l ues for a defi ned s et of a ttri butes ca n be
a dded to a ddi ti ona l Lucene i ndex fi el ds a nd then us ed wi th the _queryIndex/10 bui l t-i n or for
a utocompl eti on.
OntoBroker a utoma ti ca l l y bui l ds a n i ndex wi th s evera l predefi ned fi el ds (e.g. i d, na me_de, na me_en, a l l , ...)
for a l l ontol ogy objects i f the OntoConfi g.prp pa ra meter "Indexer" i s s et to "on".To cus tomi ze thi s i ndex, you
ha ve to a da pt the confi gura ti on fi l e "i ndexer-context.xml " l oca ted i n the confi gura ti on di rectory (defa ul ts to ./
conf rel a ti ve to the worki ng di rectory). There you ca n defi ne cus tom i ndex fi el ds for the bea n wi th the i d
"ObjectLogi cDocumentBui l der".
274
OntoBroker 6.3 Appendi x
Configuration example
...
Search Example
To s ea rch i n thi s fi el d wi th _queryIndex/10, us e the Lucene s ynta x for fi el ds (here "xna me:") i n front of your
s ea rch text.
?- _queryIndex(<http://your.company.com#ontology>, [return(xname)], "xname:Transp*",
0, 10, ?OBJ, ?TC, ?SCORE, ?ORDER, ?OPT).
Autocomplete Example
For a utocompl ete you ha ve to s et the s ea rch fi el d i n the AutoCompl ete
AutocompleteHelper helper = ...
Ontology ontology = ...
AutocompleteHelper.Type type = ...
AutocompleteHelper.Options options = new AutocompleteHelper.Options();
options.setSearchField("xname");
options.set...
275
OntoBroker 6.3 Appendi x
Configuration
If the ful l -text i ndex engi ne i s ena bl ed, i .e. the pa ra meter "Ful l TextIndex = on" i s s et i n the OntoConfi g.prp,
OntoBroker crea tes a n ful l -text i ndex for every ontol ogy.The fi el ds a nd va l ues ca n be confi gured wi th two fi l es
i n the conf di rectory:
fulltextindex-config.xml
Conta i ns the genera l opti ons a nd the defi ni ti on of the i ndex fi el ds .
fulltextindex-schema.xml
Conta i ns the i ndex s chema defi ni ti on, i .e. fi el d types a nd a na l yzers to be us ed for i ndexi ng a nd
queryi ng.
See a l s o Apa che Sol r documenta ti on wi ki .a pa che.org/s ol r/Schema Xml
In contra s t to Apa che Sol r, the i ndex fi el ds a re not defi ned i n the s chema defi ni ti on, but i n the
fulltextindex-config.xml.
Al s o note tha t the ful l text i ndex engi ne onl y works wi th extens i ona l da ta , i .e. fa cts s tored i n the OntoBroker
da ta model by i mport from ontol ogy fi l es , API i ns ert/del ete, ma teri a l i za ti on.
General Options
property Description
excl udedOntol ogi es s et of ontol ogi es , i denti fi ed by ontol ogyURI, whi ch s houl d not be ful l -text
i ndexed
l a ngua ges l a ngua ges to cons i der for repres enta ti ons , s ynonyms a nd cus tom fi el ds
wi th l a ngua ge pa ttern
defa ul tQueryOpera tor defa ul t query opera tor i f no opera tor i s s peci fi ed. Defa ul t i s OR,
a l terna ti ve i s AND, but thi s ha s a ma jor i mpa ct on the overa l l beha vi or of
the s ea rch
defa ul tStri ngMetri c s tri ng metri c us ed for fuzzy s ea rch i f not expl i ci tl y s peci fi ed. Pos s i bl e
va l ues a re e.g.
Ja ro, Levens tei n, Ja roSca l ed, Ja roWi nkl er, Da mera uLevens htei n,
Da mera uLevens htei nSca l ed, Ma xJa roDa mera uLevens htei nSca l ed, Ja cca rd,
Soundex, Smi thWa termna
276
OntoBroker 6.3 Appendi x
id object i d
type Object type: c = Concept, i = Ins ta nce, a = Attri bute, r = Rel a ti on, u = Rul e, q = Query, t =
Cons tra i nt
s yn l oca l na me, a l l repres enta ti ons a nd a l l s ynonyms (res tri cted to va l ues of l a ngua ge
property)
na me_de, l a ngua ge-dependent na mes : repres enta ti on (or l oca l na me a s fa l l ba ck i f repres enta ti on
na me_en, ... i s not defi ned), s ynonyms
277
OntoBroker 6.3 Appendi x
fi el dNa me na me of the i ndex fi el d. Attri bute 'l a ngua geAwa re' (bool ea n): If true, the
fi el dNa me i s expa nded i f i t conta i ns the l a ngua gePa ttern.
a ttri buteNa mes s et of property na mes whos e va l ue s houl d be i ncl uded i n thi s fi el d. If a n
a ttri buteNa me conta i ns the va l ue of the property l a ngua gePa ttern, i t i s
repl a ced by a concrete l a ngua ge code.
l a ngua gePa ttern pa ttern to be repl a ced by the l a ngua ge va l ues (s ee genera l opti ons a bove). In
thi s ca s e thi s fi el d defi ni ti on i s tra ns l a ted i nto mul ti pl e fi el ds .
res tri ctedToIns ta nces Of s et wi th concept i ds . The fi el d i s onl y crea ted for a n object i f i t i s a n a s s erted
i ns ta nce of one of the gi ven concept i ds
tokeni zed fa l s e: Shoul d va l ues be tokeni zed? (overwri tes va l ue from fi el d type)
omi tNorms fa l s e: a dva nced opti on: omi t norms a s s oci a ted wi th thi s fi el d (cha nges
ra nki ng). (overwri tes va l ue from fi el d type)
omi tTermFreqAndPos i ti ons fa l s e: omi t term freq, pos i ti ons a nd pa yl oa ds from pos ti ngs for thi s fi el d?
(overwri tes va l ue from fi el d type)
Configuration example
...
<bean class="com.ontoprise.indexer.FullTextIndexField">
<property name="languagePattern" value="$LANGUAGE$" />
<property name="fieldName" value="xname_$LANGUAGE$" />
<property name="fieldType" value="otext" />
<property name="stored" value="true" />
<property name="attributeNames">
<set>
<value><http://my.namespace#name>("$LANGUAGE$")</value>
</set>
</property>
</bean>
...
In thi s exa mpl e, one cus tom i ndex fi el d defi ni ti on wi th a l a ngua ge pa ttern i s defi ned. Thi s mea ns tha t
mul ti pl e i ndex fi el ds a re crea ted, one for ea ch l a ngua ge defi ned i n the property l a ngua ges (s ee gl oba l
opti ons a bove). As s umi ng tha t the defi ned l a ngua ges a re "de" a nd "en", the effecti ve i ndex fi el ds a re
"xna me_de" conta i ni ng the va l ues of the a ttri bute <http://my.na mes pa ce#na me>("de"), a nd "xna me_en"
conta i ni ng the va l ues of the a ttri bute <http://my.na mes pa ce#na me>("en"). The fi el d type us ed here i s
"otext" , thi s i s a s ta nda rd fi el d type us ed by ma ny s ta nda rd i ndex fi el ds of OntoBroker. The va l ues a re s tored
278
OntoBroker 6.3 Appendi x
i n the i ndex for retri eva l (thi s i s onl y needed i f i t i s us ed for a utocompl eti on or i f you wa nt to us e the return()
opti on of the _queryIndex bui l t-i n)
Search example
To s ea rch i n thi s fi el d wi th _queryIndex/10, us e the Lucene s ynta x for fi el ds (here "xna me_en:") i n front of
your s ea rch text.
?- _queryIndex(<http://your.company.com#ontology>, [return(xname_en)], "xname_en:
Transp*", 0, 10, ?OBJ, ?TC, ?SCORE, ?ORDER, ?OPT).
Autocomplete example
For a utocompl ete you ha ve to s et the s ea rch fi el d i n the AutoCompl ete.
AutocompleteHelper helper = ...
Ontology ontology = ...
AutocompleteHelper.Type type = ...
AutocompleteHelper.Options options = new AutocompleteHelper.Options();
options.setSearchField("xname_en");
options.set...
query - tupl e ca che i s removed a fter the query executi on. Thi s i s the defa ul t va l ue for thi s opti on for a l l
connectors i n OntoStudi o a nd for the WebServi ce connector i n Ontobroker.
unlimited - tupl e ca che i s not removed a fter the query executi on a nd ca n be us ed for the next query. Thi s
opti on i s better for performa nce a nd s houl d a l wa ys be us ed i f a da ta ba s e won't be upda ted frequentl y. The
ca che upda te s houl d be done ma nua l l y (s ee "Cl ea r connector ca che comma nd"). Thi s i s the defa ul t va l ue for
thi s opti on i n OntoBroker for a l l connectors except the WebServi ce connector.
21.8 Auditing
OntoBroker i ncl udes a n a udi t fea ture whi ch a l l ows to tra ck cha nges to the ontol ogi es i n a n OntoBroker s erver
wa s wel l a s us er a cti ons . Thes e opera ti ons a re l ogged to a fi l e whi ch ha s a n ObjectLogi c forma t a nd ca n be
rea d by OntoBroker. Audi ti ng i s not i ntended to be us ed di rectl y wi th OntoStudi o, i .e. wi th non Col l a b Server
projects . Thi s mea ns tha t a udi ti ng mus t be turned off i n the OntoStudi o OntoConfi g.prp (whi ch i s the defa ul t).
The a udi t fea ture ca n be confi gured by thes e OntoConfi g opti ons :
Auditing = off|on|detailed
If 'off' i s choos en, the a udi t fea ture i s di s a bl ed. 'on' a nd 'deta i l ed' wi l l turn a udi ti ng on. In thi s ca s e the
va l ue i s a l s o the defa ul t va l ue for a l l opera ti ons whi ch a re des i gna ted for a udi ti ng. Si ngl e opera ti ons ca n be
confi gured by
Auditing.EventType.<EventTypeName> = off|on|detailed
a nd
279
OntoBroker 6.3 Appendi x
Auditing.UserAction.<UserActionName> = off|on|detailed
Ava i l a bl e event type a nd us er a cti on na mes a re menti oned i n the defa ul t OntoConfi g.prp. For thei r mea ni ng
refer to the ObjectLogi c ontol ogy a udi t.obl , whi ch i s conta i ned i n <OntoBroker i ns ta l l a ti on di rectory>/confi g/
a udi ti ng. Thi s ontol ogy a l s o conta i ns the ObjectLogi c s chema whi ch i s us ed to l og the opera ti ons to the a udi t
fi l e. The a udi t fi l e na me ca n be choos en by
Auditing.File = <filename>
If the fi l e s i ze exceeds a l i mi t, whi ch ca n be confi gured by
Auditing.MaxFileSize = <limit>
, then the a udi t i s rol l ed over, i .e. the current a udi t fi l e i s rena med to a ba ckup fi l e a nd the a udi ti ng
conti nues wi th a new (empty) a udi t fi l e na med by Audi ti ng.Fi l e.
A ma xi mum a mount of ba ckup fi l es ca n be s peci fi ed by
Auditing.MaxBackupIndex = <max-index>
The a udi t ca n be ma nua l l y rol l ed over by us i ng the OntoBroker comma nd
auditRollOver
, whi ch ha s no further pa ra meters .
Events
Thi s i s a l i s t of l ogged events :
I.e. OntoBroker s erver s ta rtup. Thi s event does n't i ncl ude us er, hos t or s es s i on rel a ted i nforma ti on.
I.e. OntoBroker s erver s hutdown. Thi s event does n't i ncl ude us er, hos t or s es s i on rel a ted i nforma ti on.
Ontol ogy content i mported ontol ogy URI (i nto whi ch the content i s i mported)
i mported ontol ogy URI
I.e. the content of a n ontol ogy i s The a xi oms of the i mported ontol ogy i ff the a udi t l evel for thi s event
a dded to a gi ven ontol ogy type i s 'deta i l ed'
280
OntoBroker 6.3 Appendi x
Al l new a xi oms of the rena med ontol ogy i ff the a udi t l evel for thi s
event type i s 'deta i l ed'
Axi oms conta i n the i nforma ti on to whi ch ontol ogy they bel ong to. By
cha ngi ng the URI of a n ontol ogy, a l l conta i ned a xi oms a re cha nged
i mpl i ci tl y.
Ontol ogy i mport rel a ti ons hi p ontol ogy URI (of i mporti ng ontol ogy)
cha nged
ontol ogy URI of i mported ontol ogy
cha nge type: a dd/remove
For ea ch a xi om i n the l i s t:
cha nge type: a dd/remove
a xi om text
predi ca te, a rguments , modul e, i f the a xi om i s a l i tera l or F-a tom
281
OntoBroker 6.3 Appendi x
User Actions
Thi s i s a l i s t of l ogged us er a cti ons .
Opened s es s i on -
Logi n a ttempt -
Indi ca tes a l ogi n a ttempt whi ch fa i l ed.
Does n't i ncl ude s es s i on i nforma ti on, s i nce there i s none.
Cl os ed s es s i on -
OntoStudio
Audi ti ng i s a n OntoBroker fea ture. If us i ng OntoStudi o to a cces s a n OntoBroker s erver, the fol l owi ng poi nts
s houl d be cons i dered.
An OntoStudi o opera ti on l i ke del eti ng a cl a s s A ma y tri gger mul ti pl e OntoBroker events , e.g. "removed a l l
i ns ta nces of cl a s s A", "removed a l l s ub cl a s s es of A", "removed a l l s uper cl a s s es of A". I.e. a n OntoStudi o
opera ti on does not genera te a n a tomi c l og entry but ma y be refl ected by s evera l OntoBroker cha nge events .
If a udi ti ng i s ena bl ed, the ObjectLogi c Source Edi tor of OntoStudi o gets dea cti va ted.
Note:
For OntoBroker s ta rtup us e a cl ea n confi g di rectory (thi s mea ns a new fol der conta i ni ng a n ontoconfi g fi l e
wi thout a ny s ubdi rectori es ).
1. Brows e to the OntoBroker i ns ta l l a ti on di rectory [ONTOBROKER -> conf -> a udi ti ng] a nd copy the contents
of the "l og4j.properti es .obl .mi xi n" fi l e.
2. Brows e to the OntoBroker confi gura ti on di rectory [ONTOBROKER _CONFIG -> conf] a nd pa s te the contents
of the "l og4j.properti es .obl .mi xi n" fi l e i nto the "l og4j.properti es ". If there i s no l og4j.properti es i n the
confi gura ti on di rectory, copy i t from the i ns ta l l a ti on di rectory.
3. Comment the fol l owi ng l i nes :
# Set up renderers.
log4j.renderer.org.semanticweb.kaon2.api.event.DatamodelEvent=com.ontoprise.util.
logging.ObjectLogicDatamodelEventRenderer
log4j.renderer.com.ontoprise.util.logging.useraction.UserAction=com.ontoprise.util.
logging.ObjectLogicUserActionRenderer
282
OntoBroker 6.3 Appendi x
log4j.appender.auditing.layout.ConversionPattern=%m%n
log4j.appender.auditing.File=log/auditing.obl
4. Sta rt the OntoBroker Admi n Cons ol e i n s ta rt-up mode "Col l a bora ti on Server" (the s a me us er a s the OS
Col l a bora ti on us er. The defa ul t i s "Admi ni s tra tor").
5. Sta rt OntoStudi o a nd chos e "Col l a bora ti on Server" a s the s tora ge type, s et up a new project.
6. Execute the pi ng comma nd i n the OntoBroker Admi n Cons ol e.
7. Crea te a new ontol ogy (e.g. http://www.exa mpl e.com/a udi ti ng) i n your a l rea dy exi s ti ng project i n
OntoStudi o (s ee s tep 5.).
8. Crea te a cl a s s "Pers on", s et a property (na me, ra nge = s tri ng), a nd crea te a n i ns ta nce (e.g. va l ue =
Robert).
9. Del ete the cl a s s "Pers on"
10. Crea te a nother new ontol ogy (e.g. http://www.exa mpl e.com/i mportedOntol ogy)
11. Import the ontol ogy from s tep 10. to the ontol ogy crea ted i n s tep 7.
12. Crea te a cl a s s wi th a typo (e.g. Cra i n pl a ce of Ca r) i n http://www.exa mpl e.com/i mportedOntol ogy.
13. Rena me the cl a s s "Cra " to "Ca r"
14. Del ete the i mported ontol ogy i n the http://www.exa mpl e.com/a udi ti ng ontol ogy.
15. Compl etel y remove the http://www.exa mpl e.com/i mportedOntol ogy ontol ogy (a l s o from the repos i tory).
16. Remove the whol e project from OntoStudi o (do not remove the ontol ogi es from the repos i tory i n thi s
ca s e!).
17. Shut down OntoBroker
18. Crea te a new fi l e-ba s ed project (e.g. a udi ti ng).
19. Import the l og/a udi ti ng.obl ontol ogy from the confi gura ti on di rectory to the project crea ted i n s tep 18.
20. Import the "event-s chema .obl " a nd "us er-a cti ons -s chema .obl " ontol ogi es from [ONTOBROKER -> conf ->
a udi ti ng]
21. Import the "defa ul tModul e" i nto the " event-s chema .obl " ontol ogy
22. Run the query "getDa ta model Events "
Note:
Al l of the l ogged a cti ons ca n be found a s i ns ta nces i n the "defa ul tModul e" ontol ogy!
Note:
Al l l ogged a cti ons ca n be found a s i ns ta nces i n the "defa ul tModul e" ontol ogy!
21.9 Changelog
For rel eva nt cha nges i n OntoBroker 6.3 pl ea s e ta ke a l ook a t the README.TXT fi l e i n the Ontobroker
i ns ta l l a ti on di rectory.
283
OntoBroker 6.3 Index
Index -J-
Ja va 91
JDBC-Dri ver 10
-A-
Acces s Res tri cti ons 151
Attri buteNa mes Ground 163
-K-
Authenti ca ti on/Logi n 146 key fi l e 10
-B- -L-
bui l t-i ns 112 Li nked Open Da ta 22
Li nux 10
Loa d Ba l a nci ng 106
-C- l oca l hos t 36
Cha ngi ng the connecti on da ta 45 Loggi ng confi gura ti on 279
ConceptNa mes Ground 162
convert ontol ogi es 39
-M-
Mi cros oft .NET 91
-D- Mi cros oft COM 91
Defa ul t Na mes pa ce 36 mul ti pl e CPUs 159
-E- -N-
El i mi na te Bodi es 172 Na mes pa ce Al i a s es 36
El i mi na te Redunda nt Li tera l s 170 NET 109
Equa l Uni fy Rewri ter 171
Expl a na ti ons 179
Externa l Da ta ba s es 45
-O-
ObjectLogi c 12
Onl i ne Ba ckup 165
-F- OntoBroker 10
Fi l e encodi ngs a nd Uni code 183 OntoBroker Tool s 206
Ontol ogy La ngua ges 12
Ontol ogy ma ppi ngs 49
-H- opti mi za ti on 45, 84
H2 44, 163 Opti mi zers 170
hea p s i ze 10 OWL 12
-I- -P-
i ncons i s tenci es 49 Performa nce 84
i ns ta l l a ti on 10 Performa nce Tuni ng 167
Ins ta l l i ng 10 Performa nce-rel a ted s etti ngs 271
Ins ta l l i ng JDBC-Dri ver 10 Prepa red Queri es 194
Ins ta l l i ng OntoBroker 10 Project fi l es 83
Ins ta l l i ng OntoBroker under Li nux 10 Properti es Setti ngs 268
Integra ti on 45 Python 91
Integra ti on Scena ri o 49
Interfa ces 91
284
OntoBroker 6.3 Index
-Q-
Query La ngua ges 64
-R-
RAM.AVL 44
RAM.AVL.Pa cked 44
Ra nge res tri cted rul es 227
RDF/RDFS 12
rewri ter 139
rewri ter for externa l da ta ba s e a cces s 171
Rol e-ba s ed s ecuri ty 144
-S-
Schema Opti mi zer 172
Server s etti ngs 273
SPARQL 72
SQL 45
Sta rt-up s etti ngs 269
Stora ge s ys tems 44
Strong Unfol der 170
Supported i mport forma ts 63
Sys tem Requi rements 10
-T-
Termi nol ogy gl os s a ry 154
Tra ci ng 177
-W-
web s ervi ce 105
Web Servi ce Interfa ce 109
Web Servi ces 36
Webcons ol e 36
Wel l founded Eva l ua ti on 163
Wi ndows 7 10
Wi ndows Vi s ta 10
285
OntoBroker 6.3
Legal Notice
Disclaimer
All of the data and settings in this program have been checked and tested extensively. Despite taking great
care and making extensive technical checks, we cannot guarantee absolute accuracy, or completely correct
contents. No responsibility will be taken for technical errors and incorrect information or for their
consequences, e.g. effects on other programs. We are grateful to be informed of any errors at any time.
The information in this document reflects the level of information available at the time of going to press. Any
necessary corrections will be covered by subsequent versions.
semafora systems GmbH does not accept any responsibility or liability for changes caused by circumstances for
which they are not responsible.
We will accept no liability for problems with the Application Time Tracking caused by incorrect usage or for
any complications caused by third-party software.
Copyright
Parts of the technology and used names in the products OntoStudio andOnto Broker are patent or trademark
protected.
286