Download as pdf or txt
Download as pdf or txt
You are on page 1of 286

OntoBroker 6.

semafora systems GmbH


Wilhelm-Leuschner-Str. 7
64625 Bensheim
Germany
www.semafora-systems.com
OntoBroker 6.3

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

About this document


There is an Online Help and a user manual available. The Online
Help can be accessed via the Help / Help Contents menu. The user
manual is available as a PDF on the Web page
http://www.otc.semafora-systems.com/download and can be
downloaded free of charge.

The documentation describes the software on a Windows operating


system with the browser Mozilla Firefox. You can access the
information using the table of contents, the index and the full text
search. If you cannot find the answer to your question in the
helpsystem, visit free training center at http://otc.semafora-
systems.com, area "support", to get in touch with the support team.

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

Text Fi el d (For Enteri ng Text)

Sel ecti on Fi el d
(Opens by cl i cki ng on the bl a ck tri a ngl e)

Ra di o Button (i na cti ve) (a cti ve)

Check Box
(i na cti ve) (a cti ve)

Button

9
OntoBroker 6.3 Genera l Informa ti on

1.2 Typographic Conventions


Use Typographic Convention Example

Defi ni ti on or Note Outl i ned i n gra y


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, ..."

Ins tructi on Prerequi s i te Prerequisite: Prerequi s i te:


[Ins tructi on prerequi s i te] You ha ve the ri ghts to rea d a nd to
wri te to your current home
di rectory a nd the i ns ta l l a ti on
di rectory.

Ins tructi on Numbered 1. Cl i ck on File -> Import....


2. Cl i ck on Ontology from Outlook.
3. Cl i ck on Next.

Ins tructi on Annota ti on Intended Outl ook Import does not


es ta bl i s h a connecti on to i ts
s ource da ta duri ng runti me but
i mports a l l of the da ta from
Outl ook duri ng the i mport
proces s .

Ins tructi on Res ul t Not i ntended A form a ppea rs .

Code Exa mpl e Couri er New, grey ba ckground OntologyLanguage = RDF

Term (Ta b, Button or Li nk) on Bol d OK


the us er i nterfa ce

Techni ca l term, e.g. Couri er New font www.ontoprise.de


comma nd, web a ddres s ,
pa th or fi l e na me wi th fi l e
endi ng

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.

Installing OntoBroker under Linux


Before i ns ta l l i ng OntoBroker ma ke s ure you ha ve a n a ppropri a te Ja va runti me envi ronment i ns ta l l ed
(OntoBroker requi res Ja va 1.6). Then:

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)

Ja va pl a tforms Sun/OpenJDK Ja va 6 a nd l a ter

Ha rdwa re Intel or AMD proces s ors , 32-bi t or 64-bi t


Mi ni mum: 1 core, 2 GHz a nd better, 1 GB RAM, 200 MB
free ha rd di s k s pa ce
Recommended: Qua d core, 2.4 GHz a nd better, 4 GB
RAM, 400 MB free ha rd di s k s pa ce

Important Notes

About the Key File


When i ns ta l l i ng the keyfi l e, duri ng the i ns ta l l a ti on proces s you mus t ma ke s ure tha t the keyfi l e ha s the
ori gi na l na me gi ven by semafora a nd the ori gi na l extens i on »*.key.xml«. Otherwi s e the keyfi l e ha s to be
rena med a nd copi ed ma nua l l y to the i ns ta l l a ti on di rectory.

About Windows Vista/Windows 7


OntoBroker i s ful l y compa ti bl e wi th Wi ndows Vi s ta a nd l a ter vers i ons . Thi s mea ns tha t OntoBroker wi l l not
try to wri te i nto "Progra m Fi l es " etc. We recommend tha t you i ns ta l l OntoBroker to the s ugges ted defa ul t
l oca ti on of the opera ti ng s ys tem.

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

Installing MySQL Drivers


1. Cha nge OntoConfig.prp.
Add the fol l owi ng two l i nes to the confi gura ti on fi l e:
ExternalDB.OtherDatabase.Driver = com.mysql.jdbc.Driver
ExternalDB.OtherDatabase.ConnectionURL = jdbc:mysql://$host$/$name$

2. Get the MySQL JDBC dri ver.


Downl oa d a recent vers i on of the JDBC dri ver (e.g. mys ql -connector-ja va -5.1.10-bi n.ja r).
3. Convert to OSGi Bundl e.
Downl oa d bnd.jar (Bnd ca n be downl oa ded here: http://www.a qute.bi z/Code/Downl oa d).
a) Run from the comma nd l i ne: java -jar bnd.jar wrap mysql-connector-java-5.1.10-bin.
jar
As output you get mysql-connector-java-5.1.10-bin.bar
b) Rena me .mysql-connector-java-5.1.10-bin.bar to mysql-connector-java-5.1.10-bin.
jar
For more i nforma ti on, s ee:
jona s .ow2.org/JONAS_5_2_0_M1/doc/doc-en/pdf/howto_i ns ta l l _jdbc_dri ver.pdf
4. Copy to Extens i ons Di rectory
Copy the OSGi bundl e, genera ted i n the l a s t s tep to the extensions di rectory of your OntoBroker or
OntoStudi o i ns ta l l a ti on.
extensions/mysql-connector-java-5.1.10-bin.jar
5. Sta rt OntoBroker
Fi na l l y s ta rt OntoBroker or OntoStudi o.

1.4 Ontology Languages


OntoBroker s upports mul ti pl e ontol ogy l a ngua ges :
ObjectLogi c 64
RDF/RDFS 63

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 Using Ontobroker as RDF Triple Store


2.1 Introduction
OntoBroker RDF i s a n RDF tri pl e s tore, query a nd i nferenci ng engi ne. It i s wel l i ntegra ted i nto the genera l
OntoBroker s ui te, a l l owi ng cl os e i ntera cti on between the other s upported knowl edge repres enta ti on
forma ts OWL a nd ObjectLogi c. Sta yi ng cl os e to the offi ci a l Sema nti c Web s ta nda rds l i ke RDF, RDF Schema , a nd
SPARQL i s one of the pri ma ry des i gn goa l s . However, the i mpl ementa ti on on a horn l ogi c-ba s ed model
i mpos es s ome res tri cti ons i n s ta nda rd compl i a nce -- a nd s ome uni que fea tures too. Thi s document wi l l gi ve
a pra gma ti c overvi ew of OntoBroker RDF, focus i ng on RDF-rel a ted opti ons a nd fea tures . For more genera l
i s s ues , s ee the provi ded l oca ti ons i n the ma i n OntoBroker documenta ti on.

2.2 New and Noteworthy


A qui ck overvi ew of the ma jor cha nges i n OntoBroker RDF 6.2:
Support for ASK, DESCRIBE, a nd CONSTRUCT query forms
SPARQL Upda te i mpl ementa ti on
SPARQL endpoi nt for queri es a nd upda tes (i ncl udi ng JSON s eri a l i za ti on)
Us e ObjectLogi c bui l t-i ns to crea te us er-defi ned extens i on functi ons or reus e exi s ti ng bui l t-i ns

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.

For OntoBroker RDF the ontol ogy l a ngua ge ha s to be RDF.


OntologyLanguage = RDF

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

Seri a l i zi ng a ontol ogy i s provi ded by the method s a veOntol ogy.


ontology.saveOntology(OntoBrokerOntologyFileFormat.RDF_TURTLE, new File("sample-
modified.ttl"));

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.

// Execute SPARQL query


reasoner = ontology.createReasoner();
String queryText = "SELECT * WHERE { ?s ?p ?o . FILTER (?o > 30) } OPTIONS
'debug'";
query = reasoner.createQuery(Namespaces.INSTANCE, queryText);
query.open();

// show variables used


Variable[] vars = query.getDistinguishedVariables();
for (Variable var: vars) {
System.out.print(var.getVariableName() + "\t");
}
System.out.println();

// 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( ) ;

2.4.2 SPARQL Query


SELECT ca n be us ed s tra i ghtforwa rdl y by i tera ti ng a cros s the res ul ti ng va ri a bl e bi ndi ngs . However, for other
SPARQL query forms the res ul t i s not defi ned a s va ri a bl e bi ndi ngs . ASK returns a Bool ea n va l ue, CONSTRUCT
a nd DESCRIBE wi l l produce a n RDF gra ph. To rema i n compa ti bl e wi th the genera l OntoBroker query i nterfa ce
thes e res ul t types a re ma pped to s ta nda rd va ri a bl e ma ppi ngs .

2.4.2.1 Boolean Queries


For ASK queri es , the bool ea n va l ue false i s repres ented a s no query res ul ts , wherea s true i s ma pped to
exa ctl y one empty s ol uti on.

2.4.2.2 Graph Queries


The res ul ti ng gra ph of CONSTRUCT a nd DESCRIBE queri es i s repres ented a s a s et of tri pl es . Ea ch tri pl e ma ps to
one s ol uti on, provi di ng a tri pl e i ns ta nti a ti on: Va ri a bl e $s for s ubject, va ri a bl e $p for predi ca te, a nd va ri a bl e
$o for object pos i ti on.

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"

:bob vca rd:FN "Bob"

whi ch equa l s the RDF ontol ogy


@prefix : <http://www.example.com/ontology#> .
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> .
:alice vcard:FN "Alice" .
:bob vcard:FN "Bob" .

2.4.3 SPARQL Update


Upda te opera ti ons ca n be executed wi thi n the s ta nda rd comma nd fra mework of OntoBroker. The wra pper
comma nd sparqlupdate ta kes exa ctl y one a rgument whi ch s peci fi es the SPARQL Upda te s tri ng.
Exa mpl e :
ontologyManager.execute("sparqlupdate \"\"\"CLEAR DEFAULT; LOAD <http://www.w3.
org/1999/02/22-rdf-syntax-ns.rdf>\"\"\"");
The return va l ue wi l l be Bool ea n. TRUE i n ca s e of s ucces s , otherwi s e a n excepti on i s thrown. The upda te
opera ti ons a re a l s o a va i l a bl e vi a the SPARQL endpoi nt.

2.4.4 Factory Overview


RDF terms l i ke res ources a nd l i tera l s a re crea ted us i ng the KAON2Fa ctory fa ctory provi ded by KAON2Ma na ger.
fa ctory(). The ta bl e bel ow s hows a l l of the rel eva nt methods for OntoBroker RDF.

Category Element Factory method


Res ource URI/IRI res ource cons ta ntIRI

Bl a nk node cons ta ntBNode

Li tera l untyped cons ta ntSi mpl eLi tera l

l a ngua ge ta gged cons ta ntPl a i nLi tera l

bool ea n cons ta ntBool ea n

da te/ti me cons ta ntDa te


cons ta ntTi me
cons ta ntDa teTi me

dura ti on cons ta ntDura ti on

doubl e/fl oa t cons ta ntDoubl e

other numeri c cons ta ntDeci ma l


cons ta ntInteger

s tri ng cons ta ntStri ng

XML l i tera l cons ta ntXMLLi tera l

other typeCode=TypeRegi s try.getTypeCode(typeURI)


cons ta nt(va l ue, typeCode)

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 .

2.5 RDF Compatibility


2.5.1 Supported Formats
RDF i m-/export i s rea l i zed us i ng the Ses a me RDF pa rs ers . Al l common RDF s eri a l i za ti on forma ts , i .e. RDF/XML,
Turtl e, N3, a nd N-Tri pl e, a re s upported. Mos t RDF ba s ed a ppl i ca ti ons s upport RDF/XML. However, note tha t
RDF/XML i mpos es s ome res tri cti ons on the model s whi ch ca n be s eri a l i zed, s i nce the URI of a predi ca te ha s
to be s eri a l i zed a s a va l i d QNa me. In pa rti cul a r the l oca l pa rt of a QNa me ha s to be a va l i d Loca l Pa rt.
Exa mpl e:
The tri pl e
<my:subject> <my:predicate!> "object" .
ca nnot be s eri a l i zed i n RDF/XML s i nce the l a s t cha ra cter i n "predi ca te!" i s a excl a ma ti on ma rk a nd thereby
not a va l i d NCNa meCha r.

2.5.2 Internal Model and Round-Tripping


Ins i de OntoBroker RDF a l l s ta tements a re s tored i n a predi ca te-ba s ed, opti mi zed s tructure. Dependi ng on the
RDF predi ca te of a s ta tement, di fferent "ta bl es " a re us ed. By a cti va ti ng one of the na mes ground opti ons , thi s
di vers i fi ca ti on wi l l be even more s ophi s ti ca ted. Ada pti ng the RDF gra ph model to the i nterna l predi ca te-
ba s ed model i mpos es s ome res tri cti ons on da ta types . Duri ng rea s oni ng a nd query a ns weri ng, performa nce
i s of outmos t i mporta nce. One of the l i mi ti ng fa ctors , e.g. for joi n opera ti ons , i s the effi ci ent compa ri s on of
RDF terms rega rdi ng equa l i ty. Thi s pa rti cul a rl y a ffects RDF l i tera l s . For exa mpl e, compa ri ng two numeri c
l i tera l s "42"^^xs d:s hort wi th "42"^^xs d:i nteger i s more expens i ve compa red to a s i mpl y object i denti ty check
due to neces s a ry type convers i ons , a s s umi ng tha t the s a me objects s ha re thei r i denti ty, whi ch i s the ca s e i n
OntoBroker RDF. On the deci s i on between effi ci ent rea s oni ng a nd da ta type pres erva ti on we fa vored
performa nce. As a res ul t, s ome of the numeri c XML Schema da ta types a re i rrevers i bl y ma pped to a uni fi ed
i nterna l repres enta ti on. The ta bl e bel ow s hows thos e convers i ons .

Original data type Mapped data type


xs d:doubl e xs d:doubl e
xs d:fl oa t

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

xsd:double a nd xsd:float a re ma pped to xsd:double. The di fferenti a ti on between xsd:int/.../xsd:


decimal i s ba s ed on the va l ue of the l i tera l . For a uni form ma ppi ng every numeri c l i tera l i s ca s t to the da ta

18
OntoBroker 6.3 Us i ng Ontobroker a s RDF Tri pl e Store

type wi th the mi ni ma l va l ue ra nge conta i ni ng the va l ue. Therefore "32"^^xsd:integer a nd "32"^^xsd:


long a re both i nterna l l y repres ented by "32"^^xsd:int. Thi s convers i on a l s o a ffects the round-tri ppi ng
beha vi or for RDF ontol ogi es . Any other RDF terms l i ke l i tera l s wi th us er-defi ned da ta types a re pres erved.
Bl a nk nodes a re a l s o s upported. The bl a nk node i denti fi ers a re a da pted duri ng i mport i n order to ens ure
uni quenes s even i n the ca s e of gra ph mergi ng. However, thi s wi l l not a ffect the proper s ema nti cs of bl a nk
nodes .

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 .

Fi na l l y s ome i nterna l rul es a re us ed to medi a te between a s s erted a nd i nferred fa cts .


RDF.Hel per.Subcl a s s
RDF.Hel per.Subproperty
RDF.Hel per.TypeTemp
RDF.Hel per.Type

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.

2.7.1 Error Handling


Us i ng the API a nd worki ng wi th SPARQL queri es i s s tra i ghtforwa rd. If i nva l i d (i n terms of s ynta x or s upported
by OntoBroker) queri es a re s peci fi ed, one of the fol l owi ng i s s ues s houl d be checked:
Genera l s ynta x/pa rs er i s s ues : The obvi ous ca s e.
Reus e of bl a nk node i n di fferent gra ph pa tterns : Accordi ng to SPARQL defi ni ti on, i t i s prohi bi ted to s ha re
bl a nk nodes i n di fferent gra ph pa tterns .
Uns upported expres s i on: The a ri thmeti c compa ri s on of bool ea n s ub-expres s i ons i s not s upported.
Va ri a bl es not bound by gra ph pa ttern: Va ri a bl es whi ch a re not bound i ns i de a ba s i c gra ph pa ttern wi l l
ra i s e a n excepti on. Thi s i s a des i gn deci s i on to prevent the ra ther uncommon ca s e of i ntens i ona l l y
unbound va ri a bl es a nd s houl d be s een a s a error i ndi ca tor, for exa mpl e, typos i n query va ri a bl es .
Inva l i d query opti ons s ynta x: A s ynta x vi ol a ti on or unknown opti on i n the OPTIONS a rgument.
Confl i cti ng na mes pa ce defi ni ti ons : Na mes pa ces ca n be s peci fi ed i ns i de the query s tri ng a nd us i ng the
na mes pa ce a rgument for query crea ti on. If both pl a ces provi de confl i cti ng i nforma ti on, i .e. s a me prefi x
but di fferent na mes pa ce, a n excepti on i ndi ca tes thi s mi s ma tch.
Orderi ng on bool ea n expres s i ons : Expres s i ons us ed i n ORDER bl ocks a l wa ys ha ve to return non-bool ea n
va l ues .

2.7.2 Standard Conformance

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.

OPTIONAL and UNION patterns


Mul ti pl e OPTIONAL pa tterns ma y decrea s e the overa l l query performa nce.
For l i mi ta ti ons on UNION ha ve a l ook a t s ecti on Genera l /Ha ndl i ng of unbound va ri a bl es .

Expressions for FILTER and ORDER


Loca l i ty of fi l ter expres s i ons : The l oca l i ty pri nci pl e of fi l ter expres s i ons for va ri a bl e bi ndi ngs i s not
s upported. Ins tea d va ri a bl e bi ndi ngs a re gl oba l l y vi s i bl e on a l l l evel s of nes ted s tructures .
Impl ementa ti on of terna ry l ogi c: SPARQL fi l ter expres s i ons a re ba s ed on terna ry l ogi c, whi ch extends the
bool ea n l ogi c by the va l ue 'error'. Ins i de OntoBroker RDF the ma ppi ng to horn l ogi c enforces a

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.

2.7.3 Extension Functions


Expres s i ons mi ght conta i n ca l l s to extens i on functi ons . In OntoBroker thos e functi ons a re provi ded by bui l t-
i ns , a va i l a bl e i n the context of FILTER expres s i ons :
Fi l ter bui l t-i ns a re ma pped to functi ons wi th bool ea n return va l ue. There i s one l i mi ta ti on to thi s
a pproa ch: If you need the bool ea n return va l ue outs i de of bool ea n opera ti ons , e.g. a s a n a rgument for
a nother functi on, you ha ve to us e a functi ona l bui l t-i n (s ee next pa ra gra ph) returni ng a n expl i ci t bool ea n
term. However, a bui l t-i n fi l ter wi l l be s uffi ci ent for fi l teri ng i n mos t us e ca s es . For exa mpl e, you mi ght
wa nt to wri te a n fi l ter bui l t-i n wi th s i gna ture "even/1" to check i f the a rgument i s a n even number.
Another exa mpl e i s the a l rea dy exi s ti ng ObjectLogi c bui l t-i n conta i ns /2 (wi th na mes pa ce obl :res erved:)
whi ch checks i f a s tri ng i s conta i ned i n a nother s tri ng. Thi s bui l t-i n mi ght be us ed to fi l ter for tri pl es wi th
thei r object conta i ni ng the word 'hous e':
PREFIX obl: <obl:reserved:>
SELECT * WHERE { ?s ?p ?o. FILTER (obl:contains(?o, "house") }
Functi ona l (a nd rel a ti ona l ) bui l t-i ns a l l ow the returni ng of a n a rbi tra ry RDF term. Ma ppi ng i n the SPARQL
functi on s pa ce i s ba s ed on one s i mpl e a s s umpti on: The l a s t a rgument of the bui l t-i n wi l l a l wa ys be the
return va l ue. Therefore the l a s t a rgument ha s to be omi tted i f the bui l t-i n i s ca l l ed a s a functi on. For
exa mpl e, a functi on to return the di s ta nce between two geogra phi c coordi na tes , repres ented a s a us er-
defi ned da ta type wi th l a ti tude a nd l ongi tude a s one l i tera l , mi ght ha ve the functi on s i gna ture

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

2.7.4 Extended Query Options


Bes i de the s ta nda rd SPARQL s ynta x a nd s ema nti cs , OntoBroker RDF offers a ddi ti ona l query opti ons :
debug: Ena bl es debug mode wi th more deta i l ed output on the rul es a nd opti mi za ti ons .
vi s ua l Debug: Sta rt vi s ua l debugger, a Swi ng ba s ed GUI for debuggi ng.
i nferOff: Di s a bl e RDF(S) i nferenci ng.
profi l e: Informa ti on a bout pos s i bl e performa nce i s s ues .

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.

2.8 SPARQL Endpoint


OntoBroker RDF s upports a n endpoi nt provi di ng a cces s to SPARQL Query a nd SPARQL Upda te. Therefore
OntoBroker RDF ca n be us ed i n context of Li nked Open Da ta (LOD).
To a cti va te thi s web s ervi ce, ei ther us e the OntoConfi g opti on
SparqlEndpoint = on
or s ta rt the s erver wi th opti on -sparqlEndpoint. If l eft uncha nged i n the s etti ngs (opti on HttpPort), the
defa ul t port i s 8267. The pa th for the s ervi ce i s /services/sparql/query for queri es a nd /services/
sparql/update for upda tes . For exa mpl e, i f the OntoBroker web s ervi ce i s runni ng on "l oca l hos t" s ta nda rd
port 8267, the query s ervi ce i s a cces s i bl e vi a http://localhost:8267/services/sparql/query a nd the
upda te s ervi ce vi a http://localhost:8267/services/sparql/update. If no pa ra meters a re s uppl i ed
the debug mode s howi ng a s i mpl e HTML ba s ed UI i s a cti va ted.

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

About Linked Open Data (LOD):


Whi l e the tra di ti ona l web l i nks a huge a mount of huma n rea da bl e web pa ges to ea ch other the grea t
vi s i on of the Sema nti c Web crea tes a web of da ta . A l i ght-wei ght vers i on of thi s web of da ta a re l i nked
open da ta (LOD) s ources . They col l ect s tructured i nforma ti on a nd provi de thi s i nforma ti on i n LOD s ervers .
Thes e LOD s ervers a re a cces s i bl e wi th the http-protocol a nd thus by ordi na ry brows ers . Objects a re
i denti fi ed by URIs . For i ns ta nce DBpedi a i s a s ys tem extra cti ng i nforma ti on from Wi ki pedi a a nd provi di ng
thi s i nforma ti on i n a s tructured wa y a s a n LOD s erver.

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:

Parameter Type Description


query xs d:s tri ng The SPARQL query (requi red)

defa ul t-gra ph-uri xs d:a nyURI Expl i ci tl y s et defa ul t gra phs (0..n)

na med-gra ph-uri xs d:a nyURI Expl i ci tl y s et na med 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.

SPARQL Query Form Result Type Result Format (MIME)

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

CONSTRUCT Gra ph Turtl e (text/turtl e) a s defa ul t or RDF/XML (a ppl i ca ti on/


rdf+xml )
DESCRIBE

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

a l l s ervi ce a rguments , both a va i l a bl e for HTTP GET a nd POST:

Parameter Type Description

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.

Defa ul t a nd na med gra phs ?

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?

SPARQL functi ona l i ty mi ght a l s o be us ed i n combi na ti on wi th a ObjectLogi c da ta model . Ca re ha s to be


ta ken for the s l i ghtl y di fferent a xi oma ti za ti on of ObjectLogi c a nd di fferences i n ha ndl i ng/repres enta ti on
of property doma i n/ra nge i nforma ti on. Therefore the res ul t of SPARQL queri es mi ght di ffer. For l oa di ng
new ontol ogi es vi a SPARQL Upda te the ontol ogy forma t ha s to ma tch the da ta model ontol ogy l a ngua ge, e.
g. for ObjectLogi c onl y ObjectLogi c ontol ogi es ca n be l oa ded. Fi na l l y i f non-RDF-terms l i ke functi ona l terms
a re returned by SPARQL queri es thes e a re converted to s peci a l URIs (obl :term#ObjectLogi c) s i mi l a r to the
ontol ogy tra ns forma ti on.

Na mes ground opti mi za ti on?

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 .

3.1 Administration Console GUI


The OntoBroker Admi ni s tra ti on Cons ol e i s l a unched by cl i cki ng on Start -> Programs -> OntoBroker ->
Administration Console .

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

"Commands/Queries" > "Queries" tab


The us er i nterfa ce of the Admi ni s tra ti on Cons ol e cons i s ts of 3 a rea s i n the ma i n wi ndow of the Commands/
Queries ta b:

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.

2 Query On the "Query" - ta b, queri es ca n be s ent to OntoBroker a nd the a ns wers a re s hown.


Choos i ng the "Defa ul t Na mes pa ce" a nd the "Modul e" - enteri ng a nd cha ngi ng the query
- wi l l a ffect the res ul t vi ew. By a cti va ti ng the opti ons e.g. "fi l l nul l " the query wi l l be
extended a ccordi ngl y. To crea te queri es i n a n ea s i er ma nner a defa ul t modul e ca n be
chos en from the drop down menu. Thi s modul e wi l l be us ed to recei ve a ns wers from
OntoBroker. The gi ven prefi x, s hown wi thi n the "Prefi x/Na mes pa ce" fi el d, ca n be us ed
i ns tea d of the na mes pa ce.

3 Result The res ul t of your query i s s hown i n the res ul t a rea .

The History button provi des a hi s tory of your executed queri es .

27
OntoBroker 6.3 OntoBroker GUI

"Commands/Queries" > "Command" tab


Wi thi n the ma i n wi ndow of the Commands/Queries ta b there a re s evera l s ub-a rea s . The s creens hot bel ow
s hows the Command ta b a ga i n wi th i ts ta bs a nd functi ons .

Nr. Description
1 Ontology Management

2 Command Output

28
OntoBroker 6.3 OntoBroker GUI

"Commands/Queries" > "Server administration" tab


The Server administration ta b offers s evera l opti ons for ha ndl i ng comma nds or getti ng ba s i c i nforma ti on on
OntoBroker. A l i s t of a l l of the a va i l a bl e comma nds i s a l s o a va i l a bl e.

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

"Commands/Queries" > "Other" tab


The Commands/Other ta b a l l ows you to execute comma nds i n a comforta bl e wa y. Type i n a comma nd or pa s te
a comma nd from the l i s t of comma nds a nd choos e Execute. The OntoBroker-feedba ck i s s hown i n the
Command output a rea .

3.2 Starting OntoBroker


Thi s i s a s hort i ntroducti on on how to l oa d a n ontol ogy, s ta rt Ontobroker a nd ma ke a query.

1. Fi rs t of a l l you ha ve to brows e through your di rectory for your ontol ogy fi l e:

2. Sel ect your ontol ogy (here: compa ni es .obl ).

31
OntoBroker 6.3 OntoBroker GUI

3. Sta rt OntoBroker (your ontol ogy fi l e wi l l be l oa ded).

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

4. Swi tch to the Command/Queries ta b a nd connect your OntoBroker to the webcons ol e.


In a ddi ti on to the confi gura ti on a nd executi on of OntoBroker, the Admi ni s tra ti on cons ol e a l s o s erves a s
a cl i ent for demons tra ti on a nd tes t purpos es . Under the Command/Queries ta b you fi rs t ha ve to connect to
the OntoBroker. Sel ect the s erver (hos t) a nd the port a nd then cl i ck on the Connect button. When
a uthori za ti on i s requi red the us er a nd pa s s word mus t be entered i n the rel eva nt fi el ds . If the
Admi ni s tra ti on cons ol e wa s a bl e to connect to OntoBroker a s ui ta bl e mes s a ge a ppea rs .

5. Type i n your query a nd pres s Execute.


On the Query ta b, queri es ma y be s ent to OntoBroker a nd the a ns wers a re s hown. Choos i ng the "Defa ul t
Na mes pa ce" a nd the "Modul e" - enteri ng a nd cha ngi ng the query - wi l l a ffect the res ul t vi ew. By
a cti va ti ng the opti ons e.g. "fi l l nul l " the query wi l l be extended a ccordi ngl y. To crea te queri es i n a n
ea s i er wa y a defa ul t modul e ca n be chos en from the drop down menu. Thi s modul e wi l l be us ed to
recei ve a ns wers from OntoBroker. The gi ven prefi x, s hown wi thi n the "Prefi x/Na mes pa ce" fi el d, ca n be
us ed i ns tea d of the na mes pa ce.

33
OntoBroker 6.3 OntoBroker GUI

Speci a l cha ra cters ma y be us ed on the query i nterfa ce:


\n newl i ne: Li ne brea k a fter tempora ry fa cts
\" ba cks l a s h: Ma rk quotes to be a quote i ns i de of queri es
\\ doubl e ba cks l a s h: Ma rk a ba cks l a s h to be a ba cks l a s h i ns i de of queri es
The res ul t of a query i s s hown i n the Res ul t a rea .

3.3 Specifying the VM


How to s peci fy the vm OntoBroker s houl d run wi th:
1. Rena me OntoBroker.exe to OntoBroker2.exe.
2. Crea te a n OntoBroker.bat wi th
Ontobroker2 -vm "C:\Program Files\Java\jdk1.6.0_10\bin\java.exe" %*

34
OntoBroker 6.3 OntoBroker GUI

3.4 Starting the Webconsole


1. Fl a g the rel eva nt checkbox a s s hown on the s creens hot.

2. Pres s "Connect".
The OntoBroker Webcons ol e i s s ta rti ng on l oca l hos t on port 8627:

3. Type localhost:8267 i n the i nput wi ndow of your brows er a nd pres s <ENTER>.


The Webcons ol e i s now di s pl a yed. Now queri es 64 a nd comma nds 188 ca n be executed i n a comforta bl e
wa y.

35
OntoBroker 6.3 OntoBroker GUI

3.5 Webconsole 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:

Nr. Area Description


1 Modul e s peci fi es whi ch modul e i s l oa ded

2 Na mes pa ce Al i a s es Choos e a prefi x for the a ccorda nt


na mes pa ce

3 Defa ul t Na mes pa ce Choos e the defa ul t na mes pa ce

4 Query Type i n the query here

5 Query/Ca ncel Run the query or ca ncel the reques t

6 Res ul t Output Defi ne the output forma t of the query.

7 Hi s tory The hi s tory of reques ts (queri es ) i s


di s pl a yed here

8 Res ul t The res ul t of the query i s di s pl a yed here

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

"Web Services" tab


On the Web Servi ces 105 ta b, i nforma ti on on a ny Webs ervi ce s ta rted i s di s pl a yed.

Jus t cl i ck on Click here to see... to get a l i s t of a l l of the a va i l a bl e Web s ervi ces .

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.

3.6 Converting Ontologies


OntoBroker provi des a n ea s y a nd ma na gea bl e wa y of converti ng ontol ogi es to di fferent forma ts .

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.

The "Convert Tool " of OntoBroker opens .


3. Add the ontol ogy to be converted us i ng the di a l og box or us i ng dra g&drop:

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

4. Choos e the output forma t.


Keep i n mi nd tha t ca rdi na l i ti es di fferi ng from (0,1) a nd (0,*) a re not s upported by F-l ogi c a nd wi l l get l os t
duri ng convers i on. Rul es , queri es a nd ma ppi ngs a re not s upported by owl a nd rdf(s ) a nd wi l l thus not be
reta i ned. Furthermore ca rdi na l i ti es a nd s ymmetri c, i nvers e a nd tra ns i ti ve rel a ti ons a re not s upported by
RDF(S) a nd wi l l a l s o not be reta i ned.

41
OntoBroker 6.3 OntoBroker GUI

5. Choos e a na me for the converted ontol ogy a nd cl i ck on Save.

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 .

ANSI Thesaurus export


Thi s functi ona l i ty ca n be tri ggered us i ng the Ontol ogy Convers i on Tool .
The ta rget forma t s houl d be a n ASCII fi l e (or UTF-8 for s peci a l cha ra cters ) wi th extens i on .a ns i
The fi rs t l i ne s houl d conta i n a s uppl i er ID s uch a s :
SID ontoprise
where only alphanumeric characters, _ and - are allowed in the single word supplier
ID (SID).
As bl a nks a re not a l l owed nei ther i n the SID, nor i n URLs they wi l l be repl a ced wi th _
Doubl e quotes a re a l s o not a l l owed a nd wi l l a l s o repl a ced wi th _

F-logic to ObjectLogic conversion


To convert ol d F-l ogi c ontol ogi es to ObjectLogi c proceed i n the fol l owi ng wa y:
1. Sta rt the OntoBroker GUI by cl i cki ng on: Sta rt -> Progra ms -> OntoBroker -> OntoBroker Admi ni s tra ti on
Cons ol e.
2. From the top l evel menu s el ect: Tool -> Convert ontologies/fact/rules (F-logic to ObjectLogic).

42
OntoBroker 6.3 OntoBroker GUI

The "Convert Tool " of OntoBroker opens .


Proceed i n the s a me wa y a s for the other convers i on proces s des cri bed a t the begi nni ng of thi s cha pter.

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.

In order to s ta rt OntoBroker wi th thi s s tora ge s ys tem s et


Storage=RAM.AVL.Packed
i n OntoConfi g.prp.

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

5.1 Creation of database mapping rules


Database Schema Import in OntoStudio
Da ta ba s e ma ppi ng rul es wi l l be crea ted a utoma ti ca l l y when us i ng the da ta ba s e s chema i mport.

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

Database User Management and Database Configuration


For externa l da ta ba s e a cces s you wi l l need rea d a cces s to the ta bl es a nd rea d & wri te a cces s to the rel eva nt
da ta ba s e for crea ti ng tempora ry ta bl es .
The convers i on of da ta types i n a da ta ba s e ca n be di fferent from the da ta type convers i on of OntoBroker. Of
cours e i t ca n ha ppen tha t when you execute bui l t-i ns l i ke s tri ng2number on the da ta ba s e, the res ul t di ffers
from the OntoBroker res ul t. When non-tri vi a l queri es i nvol vi ng rul es wi th _dba cces s us er bui l t-i ns a re
executed, i t ca n be neces s a ry to crea te tempora ry ta bl es for s tori ng i ntermedi a te res ul ts . Therefore your
connecti on needs permi s s i ons to crea te a nd del ete tempora ry ta bl es a nd i ns ert fa cts i n thes e ta bl es .

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

5.3 Null Values


The a cces s of externa l da ta ba s es wi th the dba cces s us er bui l t-i n ma y res ul t i n nul l va l ues from the da ta ba s e.
A bui l t-i n wi th a nul l va l ue a s a n a rgument i s a s s umed to be fa l s e. As a cons equence the bui l t-i ns a re not
ca l l ed a s s oon a s a nul l va l ue occurs i n i ts a rguments .

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!

OntoConfi g Opti on:


SuppressNull = on
Defa ul t va l ue i s on.
Exa mpl e :
Ta bl e "tes t" ha s fol l owi ng rows :

id name
1 a

2 nul l

R ule:
p(?X) :- _dbaccessuser("test", F(ID,?X,NAME,?Y), "connectiondatasource").

Res ul t before the bugfi x:

?X
1

Res ul t a fter the bugfi x:

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

Query Option Fillnull


Exa mpl e:
@{q,options[fillNull]} ?- ?X:Person AND ?X[hasForename->?Y].

Res ul t:

47
OntoBroker 6.3 Da ta Integra ti on

SuppressNull = off SuppressNull = on

1,B 1,B
2,nul l 2,nul l

For more i nforma ti on on fi l l nul l , s ee the a ccorda nt cha pter 64 .

5.4 Changing the Connection Data


You ca n cha nge the connecti ons da ta by edi ti ng dba cces s us erda ta _ fa ct:
_dbaccessuserdata("key","oracle","databasename","host:port","user","password").
For more i nforma ti on on da ta i ntegra ti on, s ee the OntoStudi o Ma nua l -> Import -> Import.

Connector for tuple cache


Connector Ca che Opti ons for OntoConfi g
Connector.Database.Cache.Lifetime = query | unlimited
Connector.SPARQL.Cache.Lifetime = query | unlimited
Connector.OntoBroker.Cache.Lifetime = query | unlimited
Connector.Excel.Cache.Lifetime = query | unlimited
Connector.WebService.Cache.Lifetime = query | unlimited

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.

5.5 Connector cache clear command


clear_connector_cache all | cache key
The comma nd cl ea ns a connector ca che. Thi s comma nd ca n be executed onl y i f Ontobroker i s s ta rted wi th the
opti on Connector.*.Cache.Lifetime = unlimited.
all - a l l tupl es wi l l be del eted from the ca che.
cache key - onl y tupl es for the ca che key wi l l be del eted. The 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 .

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 .

5.7 Integration Scenario


The s cena ri o for thi s proces s wa s gi ven by the bus i nes s proces s es a round the tes ti ng of ca rs . Our cl i ent ha s a
fl eet of tes t ca rs . Thes e tes t ca rs a re conti nuous l y reconfi gured a nd then tes ted wi th thi s new confi gura ti on.
Reconfi gura ti on mea ns cha ngi ng the engi ne, cha ngi ng the gea r, cha ngi ng the el ectri c, i .e. cha ngi ng a l l ki nds
of pa rts . For cha ngi ng pa rts a l ot of dependenci es between thes e pa rts ha ve to be ta ken i nto a ccount. In
ma ny ca s es thes e dependenci es a re onl y known by certa i n huma n experts a nd thus requi re a l ot of
communi ca ti on effort between di fferent depa rtments of the ma nufa cturer, between the ma nufa cturer a nd
s uppl i ers a nd between s uppl i ers . Very often tes t ca rs ha ve been confi gured whi ch di d not work or whi ch
ha mpered the mea s urement of the des i red pa ra meters . So, ma ki ng s uch dependenci es expl oi ta bl e by
computers a l l ows for reduci ng the error ra te i n confi guri ng tes t ca rs wi th a l ower communi ca ti on effort. The
i nforma ti on on the ca r pa rts i s s tored i n a cons i dera bl e a mount of da ta ba s es fi l l ed by CAD-s ys tems ,
mea s urement va l ues , a nd s o on, whi ch ha ve to be ta ken i nto a ccount. Thes e da ta ba s es a re fed by di fferent
tool s i n di fferent depa rtments . Thes e da ta ba s es ha ve to be a cces s ed duri ng query-ti me to ens ure the
topi ca l i ty of the da ta . Duri ng thi s project a n ontol ogy ha s been devel oped whi ch s erves a s a communi ca ti on
medi um between engi neers , s erves a s a knowl edge model repres enti ng thes e compl ex dependenci es a nd
s erves a s a n i ntegra ti on model for di fferent da ta s ources . The fol l owi ng des cri bes the l a s t a s pect i n deta i l .

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 .

Data Source 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 i n our s cena ri o,
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 . In our s cena ri o, the components da ta a nd the confi gura ti on da ta i s a l rea dy ha ndl ed
comprehens i vel y i n di fferent depa rtments a nd i n di fferent i nforma ti on s ources l i ke CAD-, CAE- or CAT-s ys tems
or ERP/PPS-a ppl i ca ti ons , da ta ba s es , a nd s o on. Al l of thes e IT s ys tems a ccompa ny the whol e PLM-proces s ,
begi nni ng wi th the product des i gn a nd endi ng wi th the product rel ea s e. Our tes t confi gura ti on s ys tem, a nd
hence our ontol ogy s ys tem mus t a cces s thi s l i ve i nforma ti on to be up-to-da te, a voi d i ncons i s tent da ta a nd
a voi d a ddi ti ona l effort. An ontol ogy coul d now col l ect thes e 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 bui l di ng jus t 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 de 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.
In our ca s e we a l rea dy ha ve s uch a commonl y a ccepted l ogi ca l model : the a utomoti ve ontol ogy. Thi s ontol ogy
des cri bes s chema i nforma ti on a nd i s not yet popul a ted wi th i ns ta nces . Thi s mea ns e.g. tha t there i s a
concept motor wi th a ttri butes na me, cyl i nders , type, a nd s o on. But there i s no i nforma ti on on concrete
motors l i ke TDI V6, wi th 6 cyl i nders , fuel type s uper, a nd s o on, a va i l a bl e. Thi s i s a chi eved by a tta chi ng the
ontol ogy to one or more of the exi s ti ng i nforma ti on s ources . In the fol l owi ng we exempl i fy the ma ppi ng to a
rel a ti ona l da ta ba s e.

50
OntoBroker 6.3 Da ta Integra ti on

Database Schema Import


The fi rs t s tep i n connecti ng a n ontol ogy to a da ta ba s e i s to i mport the da ta ba s e s chema a nd vi s ua l i ze i t i n
our ontol ogy ma na gement envi ronment OntoStudi o. Benea th rel a ti ona l da ta ba s e s chema s , OntoStudi o a l s o
ha s i mport fi l ters for other s chema s l i ke RDF or OWL. In our exa mpl e we wi l l s how the a tta chment of a
da ta ba s e ta bl e motor to our ontol ogy.

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

Querying the Integration Ontology


Ma ppi ngs ca n be defi ned to di fferent RDBMS a nd a l s o to web s ervi ces a t the s a me ti me. A query to the
i ntegra ti on ontol ogy i s thus tra ns l a ted i n rea l -ti me (vi a the ma ppi ng rul es ) i nto ca l l s for a ppropri a te a cces s
bui l t-i ns whi ch i n turn a cces s the da ta s ources (i n ca s e of a n RDBMS vi a SQL queri es ) a nd tra ns l a te the
a ns wers ba ck i nto ObjectLogi c. Hence a us er or a n a ppl i ca ti on on top of the ontol ogy requi res onl y thi s s i ngl e
ontol ogy vi ew a nd wi th i t s i ngl e voca bul a ry to retri eve a l l of the neces s a ry i nforma ti on. In our s cena ri o
di fferent i nforma ti on s ources contri bute to the s a me ontol ogy. For exa mpl e, i nforma ti on on el ectroni c pa rts
i s s tored i n other da ta ba s es tha n i nforma ti on on mecha ni ca l pa rts . Informa ti on on the 3-D geometry of
objects i s s epa ra ted from thei r mecha ni ca l properti es , a nd s o on.

How to Handle Inconsistencies


It i s cl ea r tha t i n pra cti ce the di fferent i nforma ti on s ources conta i n redunda nt or even i ncons i s tent
i nforma ti on. For i ns ta nce, i n our s cena ri o, ca r types ha ve not been repres ented i n a uni que wa y. The
a s s i gnment of properti es to ca r types ha s been des cri bed wi th di fferent keys for one a nd the s a me ca r type.
For exa mpl e, keys l i ke A3/A4 ha ve been us ed to des cri be common properti es of two ca r types whi l e uni que
properti es ha ve been a s s i gned to the ca r type by a key A3. We a ga i n us e rul es a nd thus i nferenci ng to s ol ve
s uch probl ems .
?T:Car[carType->?Type, has_part->?Part]
:- _dbaccessuser("car", F( "id", ?T, "part", ?Part),
"mydbconnection") and ?Type is ?T._split("/")._memberAt(0).

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.

5.8 Supported Common Datatypes


If there i s no ObjectLogi c Cons ta nt (-), thi s mea ns tha t thi s JDBC da ta type i s not s upported by our tool s .

JDBC data type ObjectLogic Constants

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

TIMESTAMP DATETIME Web Servi ce Connector 54

TINYINT INT

VARBINARY -

VARCHAR -

Addi ti ona l Ora cl e-Speci fi c Da ta Type: NVARCHAR2, STRING

5.9 Web Service Connector

Builtin: _webserviceInfo/4 retrieves information for web service

54
OntoBroker 6.3 Da ta Integra ti on

Area Description

Us a ge _webserviceInfo(webservice input map, service, method, method


info map);

Keys i n Webs ervi ce i nput [_wsdl ->"url of wsdl",_service ->”service name”,_method-


ma p >"method name",_port->"port"]
The _s ervi ce, _method a nd _port key/va l ue pa i rs i n thi s ma p a re opti ona l a nd
ca n be l eft out, i f the WSDL conta i ns onl y one i tem of them. The s ervi ce,
method a nd method i nfo ma p a rguments mus t not be bound.

Exa mpl e ?- _webserviceInfo([_wsdl ->"http://weatherservicename/


WeatherForecastSoap?wsdl"], ?
X, ?Y, ?Z )
The web s ervi ce connector s upports a cces s on web s ervi ces .

Builtin: _webserviceAccess/3 calls a web service

Area Description

Us a ge _webserviceAccess(webservice input map, input parameter map,


output map)

Webs ervi ce i nput ma p [_wsdl ->"wsdl string",_service ->_service,_method->"method


name",_port->"port", _user->”username”, _password->”password”]
The _s ervi ce, _method a nd _port key/va l ue pa i rs i n thi s ma p a re opti ona l a nd ca n
be l eft out, i f the WSDL conta i ns onl y one i tem of them. If they a re needed, you
s houl d us e on of the va l ues returned from the _webs ervi ceInfo bui l t-i n.
If the web s ervi ce i s protected wi th Ba s i c a uthenti ca ti on, you need to provi de the
_us er, a nd _pa s s word key/va l ue pa i rs . The va l ues for the _us er a nd _pa s s word
pa ra meters mus t be fi l l ed wi th us er na me a nd the pa s s word. Pl ea s e note tha t
the WSDL mus t be a cces s i bl e freel y. If thi s i s not the ca s e, downl oa d the WSDL
ma nua l l y a nd provi de a fi l e URL to i t, e.g. "fi l e:///C:/temp/s ervi ce-to-a cces s .ws dl "

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

Exa mpl e for BASIC ?- _webserviceAccess([_wsdl->”file:///c:/protectedService.xml”,


a uthenti ca ti on _authorizationType->"BASIC", _user->"scott", _password-
>"tiger"], [...], [...], ?Result).

5.10 REST Webservice Connector


Thi s web-s ervi ce connector i s a va i l a bl e s i nce OntoBroker 6.3 a nd connects to REST-l i ke web-s ervi ces whi ch
del i ver JSON a s res ul t. A OL-ma pped equi va l ent s tructure i s returned by the connector.

Syntax
Arguments for _restWebserviceAccess/4:
_restWebserviceAccess(<service>, [invocation args], [service args], ?result)

55
OntoBroker 6.3 Da ta Integra ti on

Servi ce: The IRI to a cces s the s ervi ce


Invoca ti on a rguments : Ma p s etti ng techni ca l deta i l s for the s ervi ce i nvoca ti on
Key _method: Sel ects between _get (defa ul t) a nd _post method
Key _mime: Al l ows to expl i ci tl y s peci fy the MIME type us ed, i ns tea d of defa ul t application/json
Servi ce a rguments : Ma p wi th the a rguments s end to the s ervi ce
Res ul t: The return va l ue a s ma p/l i s t-s tructured output

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.

Google Web Search


Sea rchi ng for term "Hous e"

@{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 )"

"Hous e M.D. (TV Seri es 2004– ) - IMDb" "http://www.i mdb.com/ti tl e/tt0412142/"

"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

"a bs orpti on" 5900000

"a bs orbti on" 168000

56
OntoBroker 6.3 Da ta Integra ti on

Google Book Search


Sea rchi ng for a l l books wi th us i ng the word "Thyroi d":
@{options[outorder(?authors, ?title, ?isbn)]}

?- _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 :

authors titl isbn

"Ma ry J. Shomon" "The Thyroi d Di et: Ma na ge Your Meta bol i s m "ISBN0060524448"


for La s ti ng Wei ght Los s "

"M. Sa ra Ros entha l " "The thyroi d s ourcebook for women" "ISBN0071441611"

"Al a n L. Rubi n" "Thyroi d for Dummi es " "ISBN0471787558"

"Ma ri o Skugor, Jes s e Brya nt "Thyroi d Di s orders " "ISBN1596240210"


Wi l der"

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

"Stuttga rt" 600038

"Ma nnhei m" 311142

"Ka rl s ruhe" 288917

"Frei burg i m Brei s ga u" 217547

"Hei del berg" 145642

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"

"Ura nus "

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

user message link

"Günther Grucha l a " "Ei nfa ch a l l es Fl a chreden" <http://www.s tern.de/1676195.html >

"Ra pha el "ma de by fukus hi ma " <http://www.youtube.com/wa tch?


Schwa rzha ns " v=Jp_XM4IBWn0&fea ture=s ha re>

"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>

"Vol ker Ses s l er" """U-Ba hn -Al l ta g i n Ja pa n ! Jetzt na ch <http://www.youtube.com/wa tch?


Fukus hi ma di e neus te Errungens cha ft ! v=kRuTRp4k_MQ&fea ture=rel a ted>
Scha u's di r a n ! Echtes vi deo ! Kei n Wi tz !
"""

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

"Ba rba ra Bruhn" "Herr Si nn: Fukus hi ma IST di e <http://www.youtube.com/wa tch?


Apoka l yps e!" v=G548Hol omuo>

"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

user text date

"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"

Yahoo! Weather Forecast


A s i mpl e s ervi ce ma s hup: Fi rs t get the WOEID for Ka rl s ruhe us i ng Ya hoo's YQL, then us e the ID of the hi ghes t
ra ted res ul t (Ka rl s ruhe i n Ba den-Württemberg) to query the Wea ther Foreca s t Servi ce.
@{options[outorder(?name, ?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] AND
?places[_memberAt(0)->?karlsruhe] AND
?karlsruhe[_memberAt("woeid")->?woeid, _memberAt("name")->?name] AND
_restWebserviceAccess(<http://weather.yahooapis.com/forecastjson>, [->], ["w"->?
woeid, "u"->"c"], ?jr1) AND
?jr1[_memberByPath(_path("condition", "text"))->?condition, _memberByPath(_path
("condition", "temperature"))->?temperature].

name woeid condition temperature


"Ka rl s ruhe" "664942" "Pa rtl y Cl oudy" 18.0

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

?jr1[_memberByPath(_path("condition", "text"))->?condition, _memberByPath(_path


("condition", "temperature"))->?temperature].

name country woeid condition temperature

"Ka rl s ruhe" "DE-BW" "664942" "Pa rtl y Cl oudy" 18.0

"Ka rl s ruhe" "DE-SN" "20173635" "Pa rtl y Cl oudy" 20.0

"Ka rl s ruhe" "DE-BB" "664941" "Mos tl y Cl oudy" 21.0

"Ka rl s ruhe" "US-ND" "2430747" "Cl oudy" 13.0

"Ka rl s ruhe" "DE-MV" "664943" "Li ght Ra i n" 18.0

5.11 SPARQL Connectors

_sparqlaccess(<endpoint>, [default graphs], [named graphs], [map with


output])
The l i s ts of defa ul t a nd na med gra phs ca n be empty. The output ma p i s : [context->?C,subject->?S,
predicate->?P,object->?O].
When worki ng wi th _s pa rql a cces s , the SPAQRL query i s genera ted a utoma ti ca l l y. If you s et concrete va l ues
i ns tea d of va ri a bl es i n the output ma p, they a re us ed a s res tri cti ons for the query. The defa ul t gra ph i s
i mported a s defa ul t modul e. Onl y SPARQL Protocol s ervi ces wi th HTTP bi ndi ngs (REST-l i ke) a re s upported, no
SOAP bi ndi ngs .
Exa mpl es :
_sparqlaccess(<http://localhost:8267/services/sparql/query>, [<my:defaultGraph>],
[<my:namedGraph>], [<context->?C,subject->?S,predicate->?P,object->?O>])

_sparqlaccess(<http://localhost:8267/services/sparql/query>, [], [], [<context->?C,


subject->?S,predicate->?P,object->?O>])

_sparqlaccess(<http://dbpedia.org/sparql>, [<http://dbpedia.org>], [<http://dbpedia.


org>], [context->?C, subject->?S, predicate-><http://xmlns.com/foaf/0.1/name>,
object->?O])

_sparqlquery(<endpoint>, [default graphs], [named graphs], sparql query,


[output map]).
The l i s ts of defa ul t a nd na med gra phs ca n be empty. The output ma p mus t reference a l l va ri a bl es occurri ng i n
the s pa rql query. Onl y SELECT queri es a re s upported. Onl y SPARQL Protocol s ervi ces wi th HTTP bi ndi ngs (REST-
l i ke) a re s upported, no SOAP bi ndi ngs .
Exa mpl e:
_sparqlquery(<http://localhost:8267/services/sparql/query>, [<my:defaultGraph>],
[<my:namedGraph>], "SELECT * {?s ?p ?o}", [<"?S"->?S, "?P"->?P, "?O"->?O>])

5.12 LOD Integration


Li nki ng Open Da ta (LOD) fol l ows the l i nked da ta a pproa ch to ma ke da ta s ets a va i l a bl e on the web, a nd
defi ne l i nks between them. One of the exa mpl es i s DBpedi a , provi di ng s tructured a cces s to s tructured
content extra cted from Wi ki pedi a . Whi l e l i nked da ta i s not s peci fi c a bout the wa y the da ta s ets a re
repres ented, i n Li nki ng Open Da ta there i s a s trong focus on es ta bl i s hed W3C s ta nda rds l i ke RDF a nd SPARQL.
By provi di ng i ntegra ti on of LOD s ources OntoBroker ha s a cces s to s evera l da ta s ets , conta i ni ng a bout 30
bi l l i on RDF tri pl es , i nterl i nked by a round 500 mi l l i on RDF l i nks .

61
OntoBroker 6.3 Da ta Integra ti on

How-to Integrate a LOD Source


Si mi l a r to the da ta s chema i mport, fi rs t a da ta s ource ontol ogy wi th s chema a nd ma ppi ng rul es ha s to be
crea ted. The s chema des cri bes the s tructure of the LOD s ource, whi l e the rul es a re a cces s i ng the s ource a nd
ma ppi ng the da ta to the ontol ogy s chema .
Fi rs t s tep i n thi s proces s i s to i denti fy the SPARQL endpoi nt URL of the LOD s ource. For exa mpl e, DBpedi a
provi des thi s endpoi nt vi a http://dbpedi a .org/s pa rql . Mos t SPARQL endpoi nts provi de a n a ddi ti ona l web-
ba s ed us er i nterfa ce to tes t queri es ; therefore i t’s worth tryi ng to open thi s URL wi th your brows er.
Wi thi n the next s tep the s chema a nd ma ppi ng rul es a re crea ted. Us e the s cri pt l odi mport i n the tool s
di rectory of OntoBroker for thi s ta s k. Wi thout a ny a rguments the tool s hows a n overvi ew of the a ccepted
s ynta x:
usage: lodimport [-d <GRAPH>] -e <ENDPOINT> [-g] [-h] [-i] -l <LABEL> [-m] [-o
<PATH>]
[-s <GRAPH> | -x <ONTOLOGY>]
-d,--data-graph <GRAPH> Data graphs of the LOD source
-e,--endpoint <ENDPOINT> LOD endpoint IRI
-g,--no-global-properties Do not extract global properties
-h,--help Print this message
-i,--no-implicit-root-classes Do not extract implicit root classes
-l,--label <LABEL> Label of the LOD source
-m,--extra-metadata Extract extra metadata
-o,--output <PATH> Path to save the lifting ontologies too; default
is
the current working directory
-s,--schema-graph <GRAPH> Schema graphs of the LOD source; not to be used
with –x
-x,--external-schema <ONTOLOGY> External schema ontologies; not to be used with -s
For the DBpedi a exa mpl e the fol l owi ng confi gura ti on provi des good res ul ts :
lodimport -e http://dbpedia.org/sparql -l DBpedia -d http://dbpedia.org
-s http://dbpedia.org -g -i
There a re two ontol ogy fi l es crea ted i n the output di rectory: One conta i ni ng the s chema , the other one
conta i ni ng the ma ppi ng rul es . To tes t the i ntegra ti on l oa d both ontol ogi es a nd defi ne a n i mport rel a ti on
between the rul e a nd the s chema ontol ogy, i .e. l et the rul e ontol ogy i mport the s chema ontol ogy.
Fi na l l y, l i ke i n a ny other i ntegra ti on s cena ri o, the da ta s ource ontol ogy s houl d be ma pped to a n a ppropri a te
doma i n ontol ogy. Due to i nterna l performa nce opti mi za ti ons i t i s hi ghl y recommend to remove the i mport
rel a ti on between the da ta s ource s chema a nd rul e ontol ogy for the fi na l producti ve s etti ng.

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

6 Supported Import Formats


ObjectLogic
Thi s i s the na ti ve knowl edge repres enta ti on l a ngua ge of OntoBroker. ObjectLogi c i s the s ucces s or to F-l ogi c i n
OntoBroker a nd i nheri ts ma ny of i ts fea tures . But the s ynta x ha s been reworked to res ol ve ma ny of the F-l ogi c
us a bi l i ty i s s ues . It ha s a n extended da ta type s ys tem, a more na tura l s upport for a ggrega ti ons a nd ma ny
more i mprovements on F-l ogi c. In the s a me wa y a s F-l ogi c, i t i s a n object-ori ented a nd rul e-ba s ed l a ngua ge
a nd ha s the s a me wel l -defi ned s ema nti cs . We des cri be the s ynta x for thi s l a ngua ge i n the ObjectLogi c
reference gui de i n the OntoBroker i ns ta l l a ti on di rectory. Ontobroker provi des a n ea s y to us e F-l ogi c to
ObjectLogi c converter. For more i nforma ti on cl i ck here 39 .

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 Query Languages for ObjectLogic


OntoBroker s upports mul ti pl e query l a ngua ges . The pri ma ry query l a ngua ge (a nd the na ti ve forma t of
OntoBroker) i s ObjectLogi c. ObjectLogi c expl i ci tl y s upports da ta types a nd ha s a n fea ture-ri ch a nd cl ea n
s ynta x. Other query l a ngua ges a re res tri cted to the fea tures of the query l a ngua ge (for exa mpl e, di s juncti ve
queri es or queri es tha t conta i n Bui l t-i ns , tempora ry fa cts , a nd s o on a re onl y s upported by 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.

7.1.1 Query Options


Query opti ons a l l ow you to i nfl uence di fferent a s pects of a query.
Generi c s ynta x:
@{<query name>, options[<option1>,...<optionN>]} <query>

7.1.1.1 Handling of NULL Values: fillNULL

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

@{q1, options[fillnull]} ?- ?X:Person AND ?X[hasName->?Y].


Res ul t:
X Y
Jerry "Jerry Mouse"
Tom null

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.

7.1.1.2 Ordering Query Results: outorder


If you wa nt to s peci fy the s equence of the output va ri a bl es then you ca n us e the "outorder" query opti on. For
exa mpl e, wi th the fa cts
Man::Person.
Woman::Person.
the output of the query
@{q1, options[outorder(?X,?Y)]} ?- ?X::?Y.
wi l l be
Man,Person
Woman,Person

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

7.1.1.3 Sorting Query Results: sort


Thi s query opti on a l l ows s orti ng of the res ul t of the query.
Exa mpl e:
@{q1, options[sort(asc(?X),desc(?Y))]} ?- ?X::?Y.
Thi s exa mpl e wi l l s ort the query res ul ts i n the a s cendi ng order of bi ndi ngs for ?X a nd i n des cendi ng order of
bi ndi ngs for ?Y. It i s a l s o pos s i bl e to wri te
@{q1, options[sort(?X,desc(?Y))]} ?- ?X::?Y.
The ?X wi l l be be i nterpreted a s a s c(?X), s o tha t you ca n jus t l ea ve out the a s c(..).

7.1.1.4 Skip Sending Answers: skipSendingAnswers


Thi s opti on i s us eful i f you wa nt to mea s ure the pure query ti me wi thout I/O overhea d of s endi ng the res ul ts
or i f you jus t wa nt to check i f a s peci fi c query i s eva l ua bl e.
Exa mpl e
Ontol ogy:
p(a).
p(b).
If you execute the fol l owi ng query:
?- p(?X).
You get the res ul t
a
b
But i f you us e "s ki pSendi ngAns wers ":
@{q1, options[skipSendingAnswers]} ?- p(?X).
the query wi l l return no res ul t.

7.1.1.5 Limit the Number of Results: limit


If you wa nt to l i mi t the number of a ns wers then you ca n us e the "l i mi t" opti on. The fol l owi ng exa mpl e s hows
the combi na ti on of "l i mi t" a nd "outorder":
@{q1, options[limit(1),outorder(?Y,?X)]} ?- ?X::?Y.
In thi s exa mpl e, onl y one a ns wer wi l l be gi ven. Note tha t l i mi ti ng the number of a ns wers does not
neces s a ri l y mea n tha t the performa nce wi l l i mprove.

7.1.1.6 Tracing and Debugging: trace/visualdebug


There a re two opti ons for tra ci ng a nd debuggi ng:
tra ce
vi s ua l debug

Tracing the Evaluation: trace


In order to tra ce the eva l ua ti on proces s , s i mpl y a dd "tra ce" to a ObjectLogi c query:
@{q1, options[trace]} ?- ?X:?Y.
The tra ci ng fea ture i s des cri bed i n more deta i l i n Tra ci ng the eva l ua ti on proces s 177 .

Debugging the Evaluation with the Graphical Debugger: visualdebug

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.

7.1.1.7 Turn Off Inferencing: inferOff


You ma y tel l the OntoBroker not to do i nferenci ng for query a ns weri ng. Thi s wi l l prohi bi t the eva l ua ti on of a l l
rul es a nd you wi l l get onl y the gi ven fa cts ma tchi ng your query (onl y a s s erted fa cts a re returned, no deri ved
fa cts ):
@{q1, options[inferOff]} ?- ?X::?Y.

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.

7.1.1.8 Profile: profile


Thi s query opti on hel ps you to tra ck down performa nce probl ems . It l ogs s ome of the s ta ti s ti cs on the mos t
expens i ve rul es . Thi s query opti on i s us eful for tra cki ng down performa nce probl ems . It s hows :
The mos t expens i ve bui l ti ns a nd opera tors (e.g. joi n opera ti ons )
The mos t expens i ve rul es

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

@{r1} closure(?X,?Y,f(?Y,f(?X,nil))) :- edge(?X,?Y).


@{r2} closure(?X,?Y,f(?Y,?U)) :- edge(?Z,?Y) AND closure(?X,?Z,?U).

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

How to Interpret Profiling Results


The whol e poi nt of the "profi l e" opti on i s to gi ve s ome i dea s on where the eva l ua ti on ti me i s s pent a nd to
i denti fy the probl ema ti c rul es . The fi rs t s ecti on wi l l s how the query compi l a ti on ti me. Thi s i ncl udes pa rs i ng,
rewri ti ng a nd compi l i ng the query.
---------------------------------------------------
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).

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

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

Opera tors a re typi ca l l y


Joi n opera ti ons
Ma tch opera ti ons
Bui l t-i ns 227

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

7.1.1.9 Ignore Imports: ignoreImports


The query opti on i gnoreImports a l l ows you to run a query wi thout the i mport rul es . Import rul es norma l l y ma p
fa cts a nd rul es from the i mported modul e i nto the i mporti ng modul 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.

7.1.1.10 Distinct: distinct


The el i mi na ti on of dupl i ca tes from queri es i n ObjectLogi c ca n be s et gl oba l l y by the bool ea n confi gura ti on
opti on 'El i mi na teDupl i ca tes ' (defa ul t: on). If s et to 'off', the query opti on 'di s ti nct' ca n be us ed for i ndi vi dua l
queri es to a cti va te the el i mi na ti on of dupl i ca tes .
Thi s query opti on a l l ows you to el i mi na te dupl i ca tes for ea ch query.
@{q1, options[distinct]} ?- ?X::?Y.

70
OntoBroker 6.3 Query La ngua ges for ObjectLogi c

7.1.1.11 Offset: offset


If you wa nt to s ki p the fi rs t n res ul ts then you ca n us e the "offs et" opti on:
@{q1, options[offset(10)]} ?- ?X::?Y.
In thi s exa mpl e, onl y the a ns wers s ta rti ng from the 10th res ul t a re returned.

7.1.1.12 Maximal Query Evaluation Time: timeout


Someti mes you wi l l wa nt to s top a query a fter a s peci fi c a mount of ti me. The "ti meout" query opti on a l l ows
you to do thi s :
@{q1, options[timeout(2000)]} ?- ?X::?Y.
Thi s query wi l l be s topped a fter 2 s econds .

7.1.1.13 Tracing and Profiling: profile/trace


OntoBroker wi l l l og s ome i nforma ti on a bout the query a nd the performa nce cha ra cteri s ti cs i f you us e the
query opti ons "profi l e" a nd "tra ce".
@{q1, options[profile,trace]} ?- ?X::?Y.
@{q1, options[profile]} ?- ?X::?Y.
@{q1, options[trace]} ?- ?X::?Y

7.1.1.14 Set Evaluation Method Single Query


Us ua l l y you s peci fy
EvaluationMethod = choose
i n your OntoConfi g fi l e, s o tha t OntoBroker ca n deci de whi ch eva l ua ti on s tra tegy to us e for a query. But s ome
s peci fi c queri es mi ght be fa s ter i f you s el ect a nother eva l ua ti on s tra tegy:
@{q1, options[EvaluationMethod(BottomUp)} ?- p(?X).

7.1.1.15 Provenance Option for Queries: connectorprovenance


Thi s opti on for queri es returns provena nce i nforma ti on on how the a ns wers depend on the fa cts i n connected
i nforma ti on s ources . A l i s t of s uch provena nce i nforma ti on i s gi ven for ea ch a ns wer. Thi s l i s t provi des the
a cces s l i tera l s a nd the va ri a bl e s ubs ti tuti ons for thes e a cces s l i tera l s .

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"

If we a dd the connector provena nce opti on to the query:


@{options[connectorprovenance(?Z)]} ?- _dbaccessuser
("dbo"."Employees","F"("EmployeeID",?VAR1,"LastName",?
VAR2),"data:1433_Northwind_test").
We get the va ri a bl e ?Z bound to a l i s t of i ns ta nti a ti ons of the _dba cces s us er predi ca te:
?VAR1= 1, ?VAR2 = "Callahan", ?Z = [_dbaccessuser
("dbo"."Employees","F"("EmployeeID",1,"LastName",”Davolio”),"data:1433_Northwind_test
")] ?VAR1= 9, ?VAR2 = "Dodsworth", ?Z = [_dbaccessuser
("dbo"."Employees","F"("EmployeeID",9,"LastName","Dodsworth"),"data:1433_Northwind_te
st")]

?VAR1= 8, ?VAR2 = "Callahan", ?Z = [_dbaccessuser


("dbo"."Employees","F"("EmployeeID",8,"LastName","Callahan"),"data:1433_Northwind_tes
t")]

71
OntoBroker 6.3 Query La ngua ges for ObjectLogi c

Indi ca ti ng tha t i d = 1, l a s t na me = "Ca l l a ha n", i d = 9, l a s t na me = "Dods worth", a nd i d = 8, l a s t na me =


"Ca l l a ha n" ha s been found i n the da ta ba s e whi ch l ea d to our a ns wers .

7.1.1.16 Query option explain


For further deta i l s cl i ck here 179 .

7.1.1.17 Query option userRulesOff


The query i s executed, but us er rul es a re not cons i dered. Thi s ba s i ca l l y mea ns tha t a l l rul es whi ch a re
crea ted di rectl y (they a re typi ca l l y s hown i n the Rul es fol der i n OntoStudi o) a re not cons i dered.
@{q1, options[userRolesOff]} ?- ?X:?Y.

7.1.1.18 Query option reduced


Thi s a l l ows the pa rti a l dupl i ca te el i mi na ti on from the res ul ts of a SPARQL query. For more deta i l s cl i ck here.

7.1.1.19 Query option profileAll


profileAll wi l l l og profi l i ng-rel a ted output duri ng query executi on. The output wi l l conta i n executed joi ns
etc. Note tha t the output forma t a nd deta i l gra nul a ri ty i s eva l ua ti on-method s peci fi c.
@{q1, options[profileAll]} ?- ?X::?Y.

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 :

Subject Predicate Object ObjectLogic Comment

?S rdf:type rdfs :Cl a s s _concepts (?S) Al l cl a s s es

?S rdf:type rdf:Property _properti es (?S) Al l properti es (i .e. a ttri butes a nd


rel a ti ons )

?S rdf:type ?O ?S:?O AND ... Ins ta nces (i ncl udi ng i ns ta nces of


meta -cl a s s es rdfs :Cl a s s a nd rdf:
Property)

?S rdfs :s ubCl a s s Of ?O ?S::?O Sub-cl a s s es

?S rdfs :s ubPropertyOf ?O ?S<<?O Sub-properti es

?S rdfs :ra nge ?O _PropertyRa nge(? RDFS doma i n (not pa rt of OL)


S,?O)

?S rdfs :doma i n ?O _PropertyDoma i n RDFS ra nge (not pa rt of OL)


(?S,?O)

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
}

Thi s SPARQL query coul d a l s o be expres s ed us i ng the ObjectLogi c query


?- ?CAR:<http://example.com/#car> AND ?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

Thi s SPARQL query coul d a l s o be expres s ed wi th the ObjectLogi c query


@{options[outorder(?X)]} ?- ?X::?Y.

73
OntoBroker 6.3 Run Queri es by Query Id

8 Run Queries by Query Id


It i s pos s i bl e to run a query by query i d.
The query
?- _query_(q1)@m2.
executes the query q1 of modul e m2.

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.

Moreover thi s opti on s ubs i tutes pa rts of queri es . You ca n wri te


_query_(q1) and ?X is a.

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.

9.2 ObjectLogic -> RIF


9.2.1 Mapping
The fol l owi ng ta bl e s hows a (pa rti a l ) ma ppi ng T from ObjectLogi c cons tructs to thei r RIF/XML repres enta ti ons .
The XML enti ty "ri f" refers to the RIF na mes pa ce "http://www.w3.org/2007/ri f#" a nd the XML enti ty a nd
na mes pa ce prefi x "obl d" refer to the na mes pa ce "http://www.ontopri s e.com/2009/03/ri f/obl d#".

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->va l ue] <Frame>


<object>T(object)</object>
<slot ordered="yes">
T(property)
T(value)
</slot>
</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>

s ubcl a s s ::s upercl a s s <Subclass>


<sub>T(subclass)</sub>
<super>T(superclass)</super>
</Subclass>

s ubcl a s s <<s upercl a s s <obld:Subproperty>


<obld:sub>T(subclass)</obld:sub>
<obld:super>T(superclass)</obld:super>
</obld:Subproperty>

cl a s s [property{mi n:ma x} <Atom>


*=>()]
<op><Const type="&rif;iri">&obld;propertyCardinality</
Const></op>
<args ordered="yes">
T(class)
T(property)
T(min)
T(max)
</args>
</Atom>

cl a s s [property*=>ra nge] <Atom>


<op><Const type="&rif;iri">&obld;propertyRange</Const></op>
<args ordered="yes">
T(class)
T(property)
T(range)
</args>
</Atom>

cl a s s [property=>ra nge] <Atom>


<op><Const type="&rif;iri">&obld;
nonInheritablePropertyRange</Const></op>
<args ordered="yes">
T(class)
T(property)
T(range)
</args>
</Atom>

cl a s s [property{i nvers eOf <Atom>


(i nvers eProperty)}
<op><Const type="&rif;iri">&obld;propertyInverseOf</

76
OntoBroker 6.3 RIF

*=>i nvers eDoma i n] Const></op>


<args ordered="yes">
T(class)
T(property)
T(inverseProperty)
T(inverseDomain)
</args>
</Atom>

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>

EXIST v1, ..., vN F <Exists>


<declare>T(v1)</declare>
...
<declare>T(vN)</declare>
<formula>T(F)</formula>
</Exists>

FORALL v1, ..., vN F <Forall>


<declare>T(v1)</declare>
...
<declare>T(vN)</declare>
<formula>T(F)</formula>
</Forall>

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>

"l exi ca l Va l ue"^^<da ta typ <Const type="datatypeURI">lexicalValue</Const>


eURI>

[t1, t2, ..., tN] <Expr>


<op><Const type="&rif;iri">&obld;list/2</Const></op>
<args ordered="yes">
T(t1)
<Expr>
<op><Const type="&rif;iri">&obld;list/2</Const></
op>
<args ordered="yes">
T(t2)
...
<Expr>
<op><Const type="&rif;iri">&obld;list/2</
Const></op>
<args ordered="yes">
T(tN)
<Const type="&rif;iri">&obld;list/0</
Const>
</args>
</Expr>
...
</args>
</Expr>
</args>
</Expr>

[t1->v1, t2->v2, ..., tN->vN] <Expr>


<op><Const type="&rif;iri">&obld;map/1</Const></op>
<args ordered="yes">
T([t1,v1_1,...,t1,v1_M1,t2,v2_1,...,t2,v2_M2,...,tN,
vN_1,...,vN_MN])

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.2 Annotations and Formula IDs


ObjectLogi c formul a IDs a re ma pped to RIF a nnota ti on IDs . Whi l e ObjectLogi c a l l ows functi ona l terms a s
formul a ID, RIF a nnota ti on IDs mus t be cons ta nts of type ri f:i ri . Any cons ta nt us ed a s ObjectLogi c formul a ID
not of type ri f:i ri wi l l be encoded wi th a s peci a l URI whi l e functi ona l terms wi l l be forma tted a s a s tri ng a nd
ha ndl ed a s i f they woul d be a n xs d:s tri ng cons ta nt wi th the corres pondi ng va l ue.

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

...F@modul e... <tag>


<meta>
<Frame>
<object><Const type="&rif;iri">&obld;this</Const></
object>
<slot ordered="yes">
<Const type="&rif;#iri">&obld;module</Const>
T(module)
</slot>
</Frame>
</meta>
...
</tag>

where tag is the main tag of T(F).

Indirectly Supported ObjectLogic Features


The fol l owi ng cons tructs a re i ndi rectl y s upported onl y by us i ng s peci a l pos i ti ona l term encodi ngs . Currentl y
no a xi oma ti zi ng formul a s a re i ncl uded i n the exported ontol ogi es , i n fa ct not a l l of them ca n be a xi oma ti zed.
Bool ea n properti es (bool ea n FPropertyMember), e.g. a [p].
Property ca rdi na l i ti es (FPropertyCa rdi na l i ty), e.g. A[p{mi n:ma x}*=>()].
Property ra nge (FPropertyRa nge), e.g. A[p*=>B], A[p=>B], A[*=>p] a nd A[=>p].
Invers e properti es s peci fi ca ti on (FPropertyInvers eOf), e.g. A[p{i nvers eOf(q)}*=>B].
Symmetri c property s peci fi ca ti on (FPropertySymmetri c), e.g. A[p{s ymmetri c}*=>()].
Tra ns i ti ve property s peci fi ca ti on (FPropertyTra ns i ti ve), e.g. A[p{tra ns i ti ve}*=>()].
Queri es (Query), e.g. ?-P(?X).
Cons tra i nts (Cons tra i nt), e.g. !-P(?X).
Li s ts (s peci a l terms ), e.g. [1, 2, 3].

80
OntoBroker 6.3 RIF

9.2.5 Unsupported ObjectLogic Features


Bui l t-i ns a re currentl y not s upported. Thi s i ncl udes a ggrega tes a s a s peci a l form of bui l t-i ns .

9.3 RIF -> ObjectLogic


9.3.1 Allowed RIF Formulas
Onl y the ki nd of RIF formul a s a re a l l owed whi ch ca n be obta i ned by a ppl yi ng the ObjectLogi c to RIF/XML
tra ns forma ti on on a va l i d ObjectLogi c formul a . For exa mpl e, di s juncti ons a re a l l owed onl y i n i mpl i ca ti on
condi ti ons s i nce a di s juncti on i n a rul e hea d or a fa ct i s di s a l l owed i n ObjectLogi c. As "s ynta cti c s uga r" groups
a re a l l owed but a re ma pped to conjuncti ons . ri f:l oca l cons ta nts ma y be us ed but a re ha ndl ed i n a s peci a l
wa y, s ee bel ow.

9.3.2 Partially Supported RIF Features


Some fea tures a re s upported onl y pa rti a l l y.
Groups a re ma pped to conjuncti ons .
Cons ta nts of da ta type rif:local whi ch a re us ed a s predi ca te s ymbol s a re ma pped to na mes i ncl udi ng
the document ID i nforma ti on, i .e. "lexicalValue"@<documentId>, where lexicalValue i s the
l exi ca l va l ue of the ri f:l oca l cons ta nt a nd documentId i s the l exi ca l va l ue of the document i d. ri f:l oca l
Cons ta nts us ed i n (non formul a ) term pos i ti ons a re ma pped to ObjectLogi c bl a nk nodes , note tha t the
l exi ca l Va l ue i s not pres erved.
Fra mes wi th more tha n one property/va l ue pa i r a re s pl i t i nto a conjuncti on of fra mes conta i ni ng onl y
one property/va l ue pa i r ea ch.
The da ta types xs d:da yTi meDura ti on a nd xs d:yea rMonthDura ti on a re ma pped to da ta type xs d:dura ti on.
Pos i ti ona l terms us ed a s functi ona l terms wi th a ri ty zero a re ma pped to the cons ta nt us ed a s the
l ea di ng s ymbol . E.g. "f"^^xs d:s tri ng() i s ma pped to "f"^^xs d:s tri ng.
The l ea di ng term of a n a tomi c pos i ti ona l term mus t be a cons ta nt. The i mport ma ps a tomi c pos i ti ona l
terms to l i tera l s . Si nce the OntoBroker API onl y a l l ows s tri ngs for the predi ca te s ymbol i n l i tera l s , s ome
s peci a l encodi ngs of the l ea di ng cons ta nt a re us ed to ma p them to s tri ngs .

9.3.3 Unsupported RIF Features


The fol l owi ng RIF cons tructs a re not s upported.
Imports wi th a profi l e.
DTB bui l t-i ns a nd a ggrega ti ons , onl y ObjectLogi c ones a re s upported.
RIF l i s ts terms .
RIF remote term references a nd formul a s .
Terms wi th na med a rguments .
Annota ti ons on non top l evel formul a s .
An excepti on i s the s peci a l a nnota ti on for ObjectLogi c modul es .
Annota ti ons whi ch a re not a fra me or a group or conjuncti on of fra mes .
Non cons ta nt terms a s a l ea di ng term wi thi n a pos i ti ona l term.
Equa l i ty a s a fa ct or wi thi n the concl us i on of a top l evel i mpl i ca ti on.

Thes e RIF terms mus t be us ed i n formul a pos i ti ons onl y.


Equa l i ty.
Members hi p.
Subcl a s s .
Fra me.

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

Additional Information on the "resolve" Task:


When us i ng the res ol ve ta s k for a da ta pa th you s houl d us e a s l a s h (/) a nd not a ba cks l a s h (\).
Us e
resolve <http://www.ontoprise.com> = "myproject/testontology.obl"
i ns tea d of
resolve <http://www.ontoprise.com> = "myproject\\testontology.obl"
Thi s ha s the a dva nta ge tha t you ca n us e project fi l es on every opera ti ng s ys tem (Li nux, Wi ndows ).
If you us e l i tera l ba cks l a s hes they ha ve to be es ca ped.
For exa mpl e, you ca n wri te:
resolve <http://www.vector.com> = "project\\vector_bus_system.obl"
or (better a s the project fi l es a re then a l s o us a bl e under Li nux)
resolve <http://www.vector.com> = "project/vector_bus_system.obl"

Note tha t the es ca pi ng a l s o a l l ows to s peci fy fi l e na mes s uch a s


resolve <http://www.vector.com> = "project/vector\"_bus_system.obl"

10.1 Basic Examples


Loa d mul ti pl e ontol ogy fi l es :
load "file1.obl" // module m1
load "file2.obl" // module m2

Note:
Al l cha ra cters i n a l i ne a fter // a re comments .

Loa d a nd ma teri a l i ze mul ti pl e ontol ogy fi l es :


/*
multiline-comment
*/
load -m "file1.obl"
or
load -materialize "file1.obl"
Load a ontology file (with specification of the file format):
load -obl "file1.obl"
or
load -objectlogic "file1.obl"

Loa d a nd ma teri a l i ze a n ontol ogy fi l e:


load -m -obl "file1.obl"

83
OntoBroker 6.3 Project Fi l es

10.2 Loading an Ontology File into a Specific Module


Thi s fea ture i s es peci a l l y us eful for RDF. In the RDF ca s e we wi l l ha ve one ontol ogy per ontol ogy fi l e. But i t i s
qui te common to s pl i t l a rge ontol ogy fi l es i nto mul ti pl e s ma l l er fi l es . We coul d i mprove performa nce
s i gni fi ca ntl y i f we woul d put the content of a l l of thes e fi l es i nto a s i ngl e ontol ogy:
load "rdf1.ttl" into <m1>
load "rdf2.ttl" into <m1>
Then both fi l es a re put i nto the s a me modul e.

10.3 Performance Optimization with Project Files


Typi ca l l y ea ch ontol ogy fi l e wi l l be pl a ced i nto i ts own modul e. For performa nce rea s ons i t i s often better to
put mul ti pl e ontol ogi es i nto the s a me modul e. Exa mpl e: We ha ve two 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.

If i t i s not requi red to a cces s "m2" di rectl y, then i t i s better to wri te


load "file1.obl" // m1
resolve <m2> = "file2.obl" // 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.

11.1 Basic Usage


OntoBroker wi l l ma teri a l i ze a l l rul es i n a fi l e i f i t i s l oa ded vi a
OntoBroker32.exe -m "someRulesToBeMaterialized.obl"
If you ha ve s evera l rul es but you onl y wa nt to ma teri a l i ze s ome of them, you coul d put the rul es to be
ma teri a l i zed i n a s epa ra te fi l e.

11.2 Standard Materialization


The s ta nda rd ma teri a l i za ti on wi l l ma teri a l i ze rul es a nd s tore the deri ved fa cts i n the da ta model . It i s not
pos s i bl e to upda te the ma teri a l i za ti on a t a l a ter poi nt of ti me. The ma teri a l i zed rul es a re never a ga i n us ed
for rea s oni ng. Thi s mea ns tha t i f you a dded fa cts to the knowl edge ba s e a fter ma teri a l i za ti on, OntoBroker
wa s not a bl e to detect tha t the ma teri a l i zed rul es s houl d be a ppl i ed a ga i n. Thi s mea ns tha t when your
knowl edge ba s e cha nges , you ba s i ca l l y ha ve to res ta rt OntoBroker a nd ma teri a l i ze the rul es a ga i n (thi s ti me
wi th the new fa cts ).

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.

11.3 Updatable Materialization


Si nce vers i on 5.3 OntoBroker s upports upda ta bl e ma teri a l i za ti on. Thi s mea ns tha t when you a dd fa cts or
rul es a fter ma teri a l i za ti on, the ma teri a l i zed rul es a re re-eva l ua ted together wi th the cha nged fa cts a nd
rul es . Techni ca l l y thi s works by s epa ra ti ng the ba s e fa cts from the deri ved fa cts .

An exa mpl e: If you ha ve


Tom:Cat.
RULE r1: ?X:"Predator" :- ?X:"Cat".
a nd you wa nt to ma teri a l i ze rul e "r1" then the ma teri a l i zed fa ct
Tom:Predator.

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.

DRed (Delete and Rederive)


Thi s ma teri a l i za ti on s tra tegy works i ncrementa l l y. It crea tes a ma i ntena nce progra m whi ch a i ms to re-
eva l ua te onl y the rul es whi ch a re a ffected by the cha nges . Note tha t there a re ca s es where thi s a pproa ch
does not very wel l . A typi ca l exa mpl e i s when you ha ve ma ny connected rul es a nd s i mpl e cha nges l ea d to a
re-eva l ua ti on of mos t rul es . We a l s o experi enced probl ems when the number of rul es i s too l a rge.

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.

RFS (Rebuild From Scratch)


Thi s s tra tegy works very s i mpl e: If a cha nge occurs a l l ma teri a l i zed fa cts a re thrown a wa y. Then a l l rul es a re
ma teri a l i zed a ga i n. Thi s s i mpl e s tra tegy works es peci a l l y wel l i f
the i ni ti a l ma teri a l i za ti on i s very fa s t
cha nges do not occur very often
cha nges often a ffect ma ny rul es
If you deci ded you wa nt upda ta bl e ma teri a l i za ti on you ha ve to fi nd out whi ch upda te s tra tegy ma tches your
needs . Currentl y we s upport two upda te s tra tegi es : tri ggered upda tes a nd i mmedi a te upda tes .

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

11.4 Materialization Commands


Thi s s ecti on des cri bes how to ma na ge the ma teri a l i za ti on us i ng s erver comma nds . The comma nds ca n be
executed remotel y (e.g. vi a the webcons ol e 36 ) or vi a the API 92 (Ontol ogyMa na ger.execute()).

87
OntoBroker 6.3 Ma teri a l i za ti on

Function Syntax Description / Example

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.

Execute the Ma teri a l i za ti on (For mat_executeMaterialization Thi s comma nd wi l l tri gger a n


Upda ta bl e Ma teri a l i za ti on Onl y) i mmedi a te upda te of the
ma teri a l i za ti on.

Ma teri a l i ze rul es (for not mat_materializeRules Thi s comma nd works s i mi l a r to the


reverta bl e/not upda ta bl e <ruleIDs>, <ontologyID> "ma t_a ddRul e" comma nd, but the
ma teri a l i za ti on) ma teri a l i za ti on of thes e rul es ca n
not be upda ted a ga i n.
Thi s exa mpl e s hows how to
ma teri a l i ze a s i ngl e rul e:
mat_materializeRules r1,
comics
You ha ve to s peci fy a t l ea s t one
rul e ID. To ma teri a l i ze mul ti pl e
rul es you ca n execute
mat_materializeRules r1,
r2, r3, r4, comics

Ma teri a l i za ti on Sta tus mat_status Thi s comma nd wi l l return a s hort


s ta tus a bout the ma teri a l i zed
rul es , a nd s o on. The output wi l l
l ook l i ke thi s :
# of facts in the EDB: 132
# of rules in the IDB: 22
Materialization strategy:
RFS
Materialized rules:
@{r1} ?X[enemyOf-
>Jerry] :- ?X:Cat AND ?X
[hasName->Tom].

11.5 Tracing the Materialization


Duri ng ma teri a l i za ti on s ome i nforma ti on a bout the ma teri a l i za ti on progres s i s s hown. For debuggi ng
purpos es i t mi ght be us eful to turn on a ddi ti ona l tra ci ng:
Trace.Materialization = on
The ma teri a l i za ti on moni tor l ogs out i nforma ti on a bout the ma teri a l i za ti on proces s a nd a bout the upda tes .

88
OntoBroker 6.3 Ma teri a l i za ti on

11.6 All Configuration Options

Configuration Option Possible values / results Code

Ma teri a l i za ti on.Upda ta bl e Pos s i bl e va l ues : "on" a nd "off". Materialization.Updatable =


Thi s opti on wi l l turn on or off the on
upda ta bl e ma teri a l i za ti on.
Materialization.Updatable =
off

Ma teri a l i za ti on.Stra tegy Pos s i bl e va l ues : "DRed" a nd "RFS" Materialization.


Strategy=DRed
Materialization.
Strategy=RFS

Ma teri a l i za ti on.Upda teStra tegy Pos s i bl e va l ues : "Tri ggered" a nd Materialization.


"Immedi a tel y" UpdateStrategy=Triggered
Materialization.
UpdateStrategy=Immediately

Tra ce.Ma teri a l i za ti on Pos s i bl e va l ues : "on" a nd "off". Trace.Materialization = on


Thi s opti on wi l l s how more
i nforma ti on a bout the Trace.Materialization = off
ma teri a l i za ti on progres s .

11.7 Materialization with the API


The fol l owi ng code s hows how to s et up a new ontol ogy ma na ger wi th s ome ma teri a l i za ti on opti ons :
Properties properties = new Properties();
properties.setProperty(IConfig.MAT_UPDATABLE_KEY, IConfig.ON);
properties.setProperty(IConfig.MAT_STRATEGY_KEY, IConfig.MAT_STRATEGY_RFS);
properties.setProperty(IConfig.MAT_UPDATE_STRATEGY _KEY,
IConfig.MAT_UPDATE_STRATEGY_TRIGGERED);
OntologyManager manager = KAON2Manager.newOntologyManager(properties);
Then you can access the materialization manager by calling
MaterializationManager matManager = manager.getMaterializationManager();
Thi s ma na ger a l l ows you to a dd rul es to the ma teri a l i za ti on, to upda te the ma teri a l i za ti on etc:
matManager.materializeRule(myOntology, myRule, true); // materialize rule
matManager.materializeRule(myOntology, myRule, false); // remove from materialization
matManager.isRuleMaterialized(myOntology, myRule); // check materialization of rule
It i s a l s o pos s i bl e to ma teri a l i ze s ta nda rd a xi oms :
matManager.materializeStandardAxiom(StandardAxiom.flogicSubclassTransitivity);

11.8 Materialization of Standard Axioms


As wel l a s us er-defi ned rul es i t i s a l s o pos s i bl e to ma teri a l i ze the bui l t-i n s ta nda rd a xi oms . Sta nda rd a xi oms
a re s peci a l rul es whi ch a re us ed to, for exa mpl e, deri ve the s ubcl a s s tra ns i ti vi ty of ObjectLogi c or RDF. Often,
ma teri a l i zi ng the s ta nda rd a xi oms wi l l s i gni fi ca ntl y i mprove performa nce.

Materializing ObjectLogic Standard Axioms


If you wa nt to ma teri a l i ze the ObjectLogi c s ta nda rd a xi oms you ha ve to turn on the corres pondi ng s wi tch i n
your OntoConfi g.prp. The fol l owi ng s ta nda rd a xi oms ca n be ma teri a l i zed:
Attri bute i nheri ta nce (Ma teri a l i ze.ObjectLogi c.Attri buteInheri ta nce)
Attri butes (Ma teri a l i ze.ObjectLogi c.Attri butes )
Concepts (Ma teri a l i ze.ObjectLogi c.Concepts )

89
OntoBroker 6.3 Ma teri a l i za ti on

Rel a ti ons (Ma teri a l i ze.ObjectLogi c.Rel a ti ons )


Root concepts (Ma teri a l i ze.ObjectLogi c.RootConcepts )
Subcl a s s tra ns i ti vi ty (Ma teri a l i ze.ObjectLogi c.Subcl a s s Tra ns i ti vi ty)
Subproperty tra ns i ti vi ty (Ma teri a l i ze.ObjectLogi c.SubpropertyTra ns i ti vi ty)
Subs et rel a ti ons hi p for concepts (Ma teri a l i ze.ObjectLogi c.Subs etRel a ti ons hi p)
Subs et rel a ti ons hi p for properti es (Ma teri a l i ze.ObjectLogi c.PropertySubs etRel a ti ons hi p)
Structura l i nheri ta nce for i ns ta nces (Ma teri a l i ze.ObjectLogi c.Structura l Inheri ta nceForIns ta nces )
For exa mpl e, i f you wa nt to ma teri a l i ze the s ubcl a s s tra ns i ti vi ty s ta nda rd a xi om you ha ve to put i n your
OntoConfi g
Materialize.ObjectLogic.SubclassTransitivity = on
As a defa ul t, no ObjectLogi c s ta nda rd a xi om i s ma teri a l i zed on s ta rtup.

Materializing RDF/S Standard Axioms


When you us e the ontol ogy l a ngua ge RDF, you ca n ma teri a l i ze the RDF s ta nda rd a xi oms whi ch a re des cri bed
i n the cha pter whi ch des cri bes RDF i nferendi ng (Inferenci ng) 19 . For exa mpl e, i f you wa nt to ma teri a l i ze the
cl a s s tra ns i ti vi ty then you a dd the fol l owi ng l i ne to your OntoConfi g.prp:
Materialize.RDF.Entailment.ClassTransitivity = on
As a defa ul t, no RDF s ta nda rd a xi om i s ma teri a l i zed on s ta rtup.

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 .

12.1 Socket Client API


OntoBroker provi des a API for a cces s i ng a OntoBroker i nference s erver. The new API repl a ces the cl a s s es :
EmbeddedQueryCl i ent
EmbeddedComma ndCl i ent
QueryCl i ent
Comma ndCl i ent
The new API i s more us er-fri endl y a nd ea s i er to unders ta nd. The new API i s ba s ed on a new (bi na ry) cl i ent/
s erver s ocket protocol whi ch a l l ows fa s ter s trea mi ng of res ul t da ta .

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.

The mos t i mporta nt API i nterfa ces a re


OntoBrokerConnecti onMa na ger (crea tes connecti ons to a n i nference s erver)
OntoBrokerConnecti on (repres ents a connecti on to a n i nference s erver a nd a l l ows you to execute queri es
a nd comma nds )
ServerExcepti on (i s thrown when a n error occurs on the s erver)
Cl i entQueryCons umer (a l l ows the query res ul ts to be recei ved a s a s trea m)

When you ha ve a connecti on you ca n execute:


queri es a nd
comma nds
on the connecti on. Bes i des the s i mpl e forms of retri evi ng res ul ts (get res ul ts a s Stri ng a rra ys ) i t i s a l s o
pos s i bl e to get the res ul ts vi a a ca l l ba ck ha ndl er:
OntoBrokerConnection conn = OntoBrokerConnectionManager.getConnection();
conn.executeQuery("?- ?X::?Y.", new PrintingConsumer());

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 {

private int _resultArity;

@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, ...

12.2 OntoBroker Java API


Thi s document covers funda menta l a s pects of us i ng the Ja va API of OntoBroker 6. Its goa l i s to a cqua i nt
devel opers wi th the concepts of the API vi a us eful exa mpl es a nd i s to be s een a s a s uppl ement to the
OntoBroker API ja va doc, whi ch rema i ns the ma i n s ource of reference.
OntoBroker 6 i ntroduced numerous i nnova ti ons compa red to the l a s t ma jor rel ea s e, a mongs t others ,
ObjectLogi c repl a ced F-Logi c a s the ma i n ontol ogy l a ngua ge a nd wi l l therefore be the l a ngua ge us ed i n our
exa mpl es . As the OntoBroker Ja va API ha s a l s o s een a number of cha nges a nd i mprovements , even
devel opers wi th previ ous OntoBroker experi ence wi l l benefi t from revi ewi ng the document.
The code s ni ppets pres ented throughout the document a re kept conci s e, however, compl ete s ource code for
worki ng demo a ppl i ca ti ons i s a tta ched to the res pecti ve cha pters .

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 .

Development Environment Setup


Us i ng the OntoBroker Ja va API requi res a number of semafora a nd thi rd pa rty l i bra ri es , whi ch come pa cka ged
wi thi n the OntoBroker i ns ta l l a ti on. The s ubdi rectory i nterfa ces \devel opment\CodeExa mpl es of your OntoBroker
i ns ta l l a ti on conta i ns a n Ecl i ps e project, tha t wi l l 'compi l e' the requi red l i bra ri es i nto a s ubdi rectory. Fol l ow the
i ns tructi ons i n Rea dMe.txt (i n the project di rectory). Upon compl eti ng the s teps , you wi l l a l s o ha ve confi gured a
'Us er l i bra ry col l ecti on' tha t ca n be a dded to your own projects wi th a few cl i cks ma ki ng s ure you don't mi s s a ny
remote API l i bra ry dependency.

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

12.2.1 Ontology Management


Pri or to worki ng wi th a knowl edge ba s e, the neces s a ry ontol ogi es ha ve to be l oa ded or crea ted. After
modi fyi ng a fi l e-ba s ed ontol ogy, i t ha s to be s a ved i n order to pres erve the cha nges . Thi s topi c dea l s wi th
ontol ogy ma na gement.

93
OntoBroker 6.3 Interfa ces to OntoBroker

Opening an Existing Ontology from a File Location


If we i ntend to a cces s a n exi s ti ng ontol ogy s tored i n a fi l e, we fi rs t of a l l need to i mport i t. Ontol ogyMa na ger
conta i ns mul ti pl e overl oa ds of the i mportOntol ogy() method for doi ng thi s .
Us i ng a Fi l e pa ra meter i s conveni ent a s thi s l ets us ea s i l y s peci fy both rel a ti ve a nd a bs ol ute pa ths on the
l oca l hos t. Pl ea s e note tha t l oca l hos t mea ns the computer where your Ja va a ppl i ca ti on i s runni ng. Thi s i s not
neces s a ri l y the s a me a s the hos t on whi ch OntoBroker i s runni ng.
// open an ontology from a file
File ontologyFile = new File("resources/ontology.obl");
Ontology ontology = OntologyManager.importOntology(ontoFile, null);
Another a l terna ti ve i s to us e one of the phys i ca l URI overl oa ds ; thi s i s es peci a l l y s ui ta bl e for i mporti ng
ontol ogi es l oca ted on a Web s erver, a l though the 'fi l e://' ps eudoprotocol ca n be us ed to s peci fy pa ths on the
l oca l fi l e s ys tem.
// open an ontology from a web url
String ontologyPhysicalUri = "http://example.org/ontology.obl";
Ontology ontology = OntologyManager.importOntology(ontologyPhysicalUri, null);
For i mporti ng mul ti pl e ontol ogy fi l es a t once, overl oa ds exi s t for both pa ra meter types . There i s a l s o one
a ddi ti ona l pa ra meter i n a l l the overl oa ds , the ProgressListener; thi s a l l ows for progres s noti fi ca ti ons of the
cl i ent code, s ee Progres s Li s tener 102 for more i nforma ti on.

Creating a New Ontology


Ha vi ng i ni ti a l i zed a n Ontol ogyMa na ger i ns ta nce, i t ca n be us ed to crea te a new ontol ogy. Onl y the
ontol ogyURI mus t be pa s s ed to the method, nul l i s a l l owed i n pl a ce of the a ddi ti ona l opti ons pa ra meter:
// create a new ontology
Ontology ontology = manager.createOntology("http://www.example.org/MyOnto", null);
Note tha t the ontol ogy URI i s a purel y l ogi ca l concept a nd a l though i t ma y res embl e a web URL, i t does not i n
a ny wa y determi ne the fi l e na me or phys i ca l l oca ti on upon s a vi ng. Al s o reca l l how the (l ogi ca l ) URI i s
di fferent from the concept of a na mes pa ce. Whi l e a na mes pa ce ca n s pa n mul ti pl e ontol ogy fi l es , there mus t
be a one-to-one corres pondence between ontol ogy fi l es a nd URIs . A (l ogi ca l ) URI corres ponds to wha t i s
referred to a s a modul e i n F-Logi c.

Saving an Ontology to a File


Whether you crea ted a new ontol ogy, or modi fi ed a n exi s ti ng one, i t ha s to be s a ved to a fi l e to pres erve the
cha nges . Sa vi ng a n ontol ogy to a fi l e wi th the method s a veOntol ogy i s s tra i ghtforwa rd; bes i des the fi l e
forma t, onl y the ta rget mus t be provi ded. However, i t i s a dvi s a bl e to expl i ci tl y s peci fy the text encodi ng to
prevent probl ems wi th a ccented or na ti ona l cha ra cters i n a mul ti -pl a tform s etti ng.
Overl oa ded vers i ons of the method a l s o exi s t a l l owi ng wri ti ng a n ontol ogy to a a n OutputStrea m or a Wri ter.
// save ontology to a file
File targetFile = new File("MyOntoFile.obl");
ontology.saveOntology(OntoBrokerOntologyFileFormat.OBJECTLOGIC,
targetFile, SerializationConstants.ENCODING_UTF);

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 Data Manipulation

12.2.2.1 Retrieval

Queries vs. Requests


There a re two funda menta l wa ys of retri evi ng i nforma ti on from OntoBroker. Ans weri ng queri es i nvol ves

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.

Choice of the Retrieval Method


The choi ce of retri eva l method a l s o determi nes the form res ul ts a re returned i n. When a ns weri ng a query,
OntoBroker l ooks for va ri a bl e a s s i gnments a ppl i ca bl e to the condi ti ons you s ta te i n the query; therefore,
wha t i s returned a re n-tupl es of qua l i fyi ng va ri a bl e va l ues deri ved from the known fa cts . The form of thes e
tupl es ma y or ma y not di rectl y corres pond to tha t of the fa cts i n the knowl edge ba s e.
As a n exa mpl e of the l a tter, cons i der queryi ng a depa rtment of motor vehi cl es knowl edge ba s e for the
a vera ge number of s peed l i mi t vi ol a ti ons dependi ng on the vehi cl e ca tegory. As s umi ng thi s i nforma ti on i s
not s tored a s a fa ct, a n a ttempt to modi fy a tupl e from s uch a res ul t s et a nd s ubmi t i t ba ck to OntoBroker
woul d not be mea ni ngful a s i t does not di rectl y corres pond to a n a ctua l object i n the knowl edge ba s e. Thi s i s
how queri es a re to be s een.
However, a ns weri ng reques ts fetches objects from the knowl edge ba s e the wa y they were expl i ci tl y entered.
Thi s mea ns tha t a record i n the reques t res ul t s et di rectl y corres ponds to a record i n the knowl edge ba s e a nd
a s s uch, ca n be ea s i l y del eted or modi fi ed. Hence, thi s retri eva l method i s es peci a l l y of i nteres t when
progra mma ti ca l l y modi fyi ng a knowl edge ba s e.

Queries Without Reasoning


When rea s oni ng i s not des i red but reques ts a re not s ui ta bl e, there i s a n a ddi ti ona l retri eva l method. Us i ng
the i nferoff opti on di s a bl es rea s oni ng for a query whi l s t ma i nta i ni ng the grea ter degree of fl exi bi l i ty of
queri es .As a n exa mpl e, cons i der the fol l owi ng query; i t wi l l onl y retri eve di rect i ns ta nces of the concept a rea ,
i gnori ng a ny i ns ta nces of i ts pos s i bl e s ubconcepts .
@{options[inferoff]} ?- ?A:Area.

12.2.2.11 Queries

Queryi ng through the API occurs i n three s teps :


1. Obtaining a Reasoner objects and Creating a Query.
Queri es ca n be crea ted from ObjectLogi c code, or retri eved from the knowl edge ba s e. In the exa mpl e bel ow,
we defi ne a query di rectl y us i ng ObjectLogi c.
Note the us e of the outorder opti on, i t l ets you l ea ve out a ny unneces s a ry hel per va ri a bl es from the res ul t s et
a nd provi des confi dence concerni ng i ndex ra nge a nd el ement l oca ti on when l a ter a cces s i ng va l ues i n a
res ul t a rra y.
Reasoner reasoner = ontology.createReasoner();
String queryText = "@{options[outorder(?D, ?T)]} " +
"?- ?M:Measurement[atDate->?D[_month->1], hasTemperature->?T].";
Query query = reasoner.createQuery(ns, queryText);

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#";);

2. Opening the Query and Processing the Results.


Upon ca l l i ng the open method of a query, i t i s s ubmi tted to OntoBroker. As expl a i ned a bove, a res ul t s et i s
formed by a number of n-tupl es , where n i s the number of va ri a bl es conta i ned i n the query. The number of
tupl es depends on the query a nd the knowl edge ba s e, i t ca n a l wa ys be a s i ngl e tupl e for a n a ggrega ti on
query, or a l a rge number. However, you s houl d a l wa ys ha ndl e the ca s e of a n empty res ul t s et. (Thi s ma y be
s urpri s i ng a t fi rs t but, for exa mpl e, the count a ggrega te functi on res ul ts i n a n empty res ul t s et ra ther tha n a
s i ngl e tupl e hol di ng a zero when no records a re found).

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();

3. Closing the Query.


To prevent a res ource l ea k, remember to cl os e your query. As excepti ons ca n occur when queryi ng, thi s i s
typi ca l l y done i n a fi na l bl ock.
query.close();

Working with Data Types


Query res ul ts a re returned a s a n a rra y of the generi c type Term, the concrete type of the va ri a bl es depends on
wha t you queri ed for. For exa mpl e, queryi ng for s i mpl e a ttri bute va l ues yi el ds a Cons ta nt. Ha vi ng s ucces s ful l y
ca s t a Term to Cons ta nt, the method Cons ta nt.getTypeURI() s houl d provi de s uffi ci ent gui da nce a s to wha t Ja va
da ta type, the a ctua l va ri a bl e va l ue returned by Cons ta nt.getVa l ue() ca n be ca s t to. However, the preferred wa y
to get a concrete va l ue i s us i ng the TypeRegi s try cl a s s :
// Extract a double typed temperature
if (TypeRegistry.isDouble(tuple[1])) {
Double value = TypeRegistry.getDouble(tuple[1]);
}

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.

Obtaining a Request Object


Axi oms ca n be retri eved us i ng a Reques t object; a Reques t i ns ta nce ca n be obta i ned by ca l l i ng the Ontol ogy
method crea teAxi omReques t. An a xi om type mus t be pa s s ed to thi s method, vi rtua l l y a l l s ubcl a s s es of Axi om
a re a dmi s s a bl e. The s a mpl e code bel ow crea tes a reques t for a xi oms of type FCl a s s Member, i n other words ,
for a xi oms ca rryi ng the i nforma ti on on wha t objects a re i ns ta nces of wha t concepts .
Request<FClassMember> request = geographyOnto.createAxiomRequest(FClassMember.class);

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

String cityLocal = ((IRIHolder) (((Constant) ax.getObject()).getValue())).


getLocal();
String stateLocal = ((IRIHolder) (((Constant) ax.getValue()).getValue())).
getLocal();
String propLocal = ((IRIHolder) (((Constant) ax.getProperty()).getValue())).
getLocal();
System.out.printf("%-20s [ %20s -> %-20s ]%n", cityLocal, propLocal,
stateLocal);
}

Knowing the Right Axiom Type


When uns ure a bout how a pa rti cul a r ObjectLogi c cons truct i s repres ented i n the Axi om form (whi ch i s
neces s a ry for correctl y s etti ng the reques t condi ti on), there i s a n a l terna ti ve to a l engthy tri a l -a nd-error bra i n
exerci s e. The KAON2Fa ctory cl a s s provi des a method for crea ti ng a xi oms from a n ObjectLogi c expres s i on.
Ins pecti ng the res ul t of a code s ni ppet l i ke the one bel ow s houl d qui ckl y get you ba ck on the ri ght tra ck. (A
s i mi l a r check ca n obvi ous l y be done i n the debugger.)
List<Axiom> axioms = KAON2Manager.factory().axioms(
"Offenburg:City[hasName->\"Offenburg\", "
+ "hasPopulation->59171, partOfFederalState->BW].",
namespaces, geographyOnto.getModule());
for (Axiom ax : axioms) {
String className = "";
if (ax instanceof FClassMember)
className = "FClassMember";
else if (ax instanceof FPropertyMember)
className = "FPropertyMember";
else if ...

12.2.2.13 Concept Hierarchy

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.

Simple Add or Remove


Indi vi dua l or mul ti pl e a xi oms ca n be a dded or removed by ca l l i ng the a ppropri a te method of the Ontol ogy
cl a s s . In the code s ni ppet bel ow, a n a xi om i s crea ted us i ng the KAON2Fa ctory a nd s ubs equentl y a dded to a n
ontol ogy:
Axiom axComp = factory.fclassMember(
factory.constantIRI(namespaces, "Heidelberg"),
factory.constantIRI(namespaces, "City"));
geographyOnto.addAxiom(axComp);

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
());

Adding or Removing Multiple Axioms


Mul ti pl e a xi oms ca n be a dded or removed equa l l y ea s i l y:
String axiomText = "Offenburg:City[hasName->\"Offenburg\" hasPopulation->59171,
partOfFederalState->BW].";
List<Axiom> axioms = factory.axioms(axiomText, namespaces, geographyOnto.getModule
());
geographyOnto.addAxioms(axioms);
...
geographyOnto.removeAxioms(axioms);

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 .

12.2.3 Datamodel Listener


The OntoBroker API provi des a conveni ent mecha ni s m fol l owi ng the obs erver pa ttern for noti fyi ng cl i ent code
a bout cha nges i n a n ontol ogy. A l i s tener ca n onl y be regi s tered for s el ected ontol ogi es a nd pa rti cul a r event
types i f des i red.
Demo progra m output:
Initial average temperature: 12,000
New avg temperature: 13,100
New avg temperature: 14,400

99
OntoBroker 6.3 Interfa ces to OntoBroker

New avg temperature: 15,600

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

public void handleEvent(DatamodelEvent event) {


if (event instanceof AxiomsUpdatedEvent) {
for (OntologyChangeEvent chEvent : ((AxiomsUpdatedEvent) event)
.getChanges()) {
if(chEvent.getChangeAction() == ChangeType.ADD) {
Axiom ax = chEvent.getAxiom();
System.out.println("Axiom added: " + ax.toString(form);
}
}
}
}
}

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

manager.addDatamodelListener(new AddListener(), filter);

Controlling a Listener Lifecycle


Upon regi s teri ng, events s ta rt bei ng i mmedi a tel y pa s s ed to the l i s tener. Ca l l i ng the Ontol ogyMa na ger
method removeLi s tener wi l l deregi s ter the l i s tener a ga i n. The method upda teDa ta model Li s tenerFi l ter
a l l ows you to a djus t the fi l ter a ppl i ed.

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]");

Retrieving Completion Suggestions


At thi s poi nt, a fi rs t s et of compl eti on res ul ts ca n be retri eved. Suppos e our ontol ogy conta i ns three i ns ta nces
of concept Pers on: Ja cki e, Ja mes a nd Ji m. The us er fi rs t types a "j", tha t corres ponds to the s ta rtStri ng
pa ra meter i n the code bel ow. Cons equentl y, a l l three i ns ta nces a re fetched a nd output. The us er then
conti nues by typi ng a n "a ". Some i nput ha ndl i ng method ca l l s our code a ga i n, thi s ti me wi th the s ea rchStri ng
"ja ". Thi s ti me a round onl y the i ns ta nces Ja cki e a nd Ja mes a re outputted.
CompletionResults results

101
OntoBroker 6.3 Interfa ces to OntoBroker

= helper.getCompletion(ontology, options, Type.Instance, startString, 0, 20);

for (CompletionElement elem : results.getStartingResults()) {


model.addElement(elem);
System.out.println(elem.getDisplay());
}

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.

12.2.5 Progress Listener


Sel ected methods wi th potenti a l l y l engthy executi on ta ke a n opti ona l a rgument of type ProgressListener.
ProgressListener s peci fi es a n i nterfa ce, through whi ch thes e l ong runni ng opera ti ons ca n provi de feedba ck
to the cl i ent code.

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();

Implementing the ProgressListener Interface


For rea s ons of s i mpl i ci ty, the cl a s s repres enti ng the ma i n a ppl i ca ti on fra me di rectl y i mpl ements the
Progres s Li s tener i nterfa ce. The methods s i mpl y di s pl a y text mes s a ges a bout opera ti on progres s i n a text
a rea . Addi ti ona l l y, method ca l l s i ndi ca ti ng opera ti on termi na ti on cha nge the form s ta te to i ndi ca te the
i mport opera ti on i s no l onger executi ng.
public void workUnitCompleted(int workUnitsCompleted, int totalWorkUnits) {
outputText("Completed " + workUnitsCompleted);
}
public void operationCompleted() {

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);
}});}}

12.2.6 Namespaces and Modules


In ObjectLogi c, there a re two wa ys of orga ni zi ng ontol ogy el ements : modul es a nd na mes pa ces . Both ca n be
us ed concurrentl y a nd i ndependentl y of ea ch other. The di fference between the two ma y s eem s ubtl e i n
s ome s i tua ti ons , yet i t i s i mporta nt to unders ta nd a nd di fferenti a te them a s they a re powerful cons tructs tha t
a re encountered frequentl y. Thi s cha pter wi l l bri efl y cl a ri fy the di fferences a nd then expl a i n how the two
concepts a re refl ected i n the OntoBroker API.
Output from a demo progra m (rea d further for expl a na ti on):
Printing concepts from all modules from namespace: http://example.org/animals#
Concept Module
http://example.org/animals#Cobra http://example.org/Europe
http://example.org/animals#Fox http://example.org/America
http://example.org/animals#Jaguar http://example.org/America
http://example.org/animals#Mustang http://example.org/America
http://example.org/animals#Viper http://example.org/Europe

Printing concepts from all modules from namespace: http://example.org/cars#


Concept Module
http://example.org/cars#Cobra http://example.org/America
http://example.org/cars#Fox http://example.org/Europe
http://example.org/cars#Jaguar http://example.org/Europe
http://example.org/cars#Mustang http://example.org/America
http://example.org/cars#Viper http://example.org/America

The Difference Between namespaces and modules


When worki ng wi th a s i ngl e ontol ogy, i t corres ponds to exa ctl y one modul e. The modul e na me i s norma l l y
nea r the top of ea ch ontol ogy fi l e. Beca us e of thi s one-to-one corres pondence, the modul e na me i s
s ometi mes a l s o ca l l ed the ontol ogy na me (e.g. i n OntoStudi o). If you reca l l how ontol ogy fi l es a re l oa ded
from the cha pter on Ontol ogy Ma na gement, you wi l l a l s o noti ce a one-to-one corres pondence between
ontol ogy fi l es a nd i ns ta nces of the Ontol ogy cl a s s . The terms modul e, ontol ogy, a nd ontol ogy fi l e ma y thus be
us ed i ntercha ngea bl y, a s l ong a s the noti on of a phys i ca l conta i ner for ontol ogy el ements des cri bed a bove i s
mea nt.
On the other ha nd, na mes pa ces repres ent a l ogi ca l concept whi ch s erves the purpos e of na mi ng a nd referri ng
to ontol ogy el ements una mbi guous l y. Thi s i s i ndependent of modul es : one modul e ma y conta i n el ements
from mul ti pl e na mes pa ces a nd one na mes pa ce ma y s pa n s evera l modul es .
For i l l us tra ti on purpos es , cons i der the a bove l i s ti ng; the fi rs t ha l f a re concepts from a n '...a ni ma l s '
na mes pa ce, l ooki ng a t the i ndi vi dua l concepts , you wi l l noti ce they come from two di fferent modul es : '...
Europe' a nd '...Ameri ca '. In the s econd ha l f of the l i s ti ng, you wi l l s ee concepts wi th the s a me l oca l na mes a s
a bove wi th a di fferent na mes pa ce a s s i gned, whi ch di s a mbi gua tes them. In a nuts hel l , modul es (Europe,
Ameri ca ) repres ent a 'phys i ca l ' orga ni za ti on, wherea s na mes pa ces (ca rs , a ni ma l s ) ca pture a l ogi ca l
orga ni za ti on.

103
OntoBroker 6.3 Interfa ces to OntoBroker

Namespaces and modules in the OntoBroker API


In thi s pa rt, we wi l l demons tra te how na mes pa ces a nd modul es a re ha ndl ed i n the OntoBroker API. Al though,
the exa mpl es onl y cover a ddi ng concepts to exi s ti ng ontol ogi es , thi s s houl d res ul t i n a n i ntui ti ve
unders ta ndi ng tha t ca n a l s o be a ppl i ed to other ta s ks .
The exa mpl es a s s ume the exi s tence of two ontol ogi es , Ameri ca a nd Europe, whos e contents a re l i s ted a bove.
Both ontol ogi es conta i n concepts from a ca rs na mes pa ce a s wel l a s from a n a ni ma l s na mes pa ce; note tha t
the concepts a bove a re l i s ted a ccordi ng to the na mes pa ce, not the ontol ogy (modul e).
NOTE: There a re certa i nl y better wa ys to model ca rs a nd a ni ma l s peci es tha n a s unrel a ted concepts .
We i ntend to a dd the ta xi a nd pol i ce fa vori te Chevrol et Impa l a to the 'Ameri ca ' ontol ogy. We a l rea dy ha ve the
neces s a ry ontol ogy object (a meri ca Onto). Thus , we onl y need to crea te the neces s a ry a xi om, thi s ca n be
a chi eved us i ng one of the a xi om fa ctory methods . We need to expl i ci tl y s peci fy not onl y the 'ca rs ' na mes pa ce
to ma ke i t cl ea r tha t we do not mea n the a ntel ope but a l s o the modul e, otherwi s e a n a ttempt to a dd the
a xi om to a n ontol ogy woul d fa i l .
// add Impala to cars in America
// module explicit as text
// namespace explicit as text
Axiom ax = KAON2Manager.factory().axiom(
"<http://example.org/cars#Impala>[]@<http://example.org/America>.",null);
americaOnto.addAxiom(ax);

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.

Querying modules and namespaces in ObjectLogic


Let us fi ni s h up the s ecti on wi th a ti p for a n ObjectLogi c query tha t ma y fi nd us eful when experi menti ng wi th
modul es a nd na mes pa ces ; i t l i s ts concepts from a l l modul es a nd a l l na mes pa ces currentl y l oa ded.
?- ?C[]@?M AND ?C[_localName->?LN, _namespace->?NS].

104
OntoBroker 6.3 Interfa ces to OntoBroker

12.3 OntoBroker and Web Services (SOAP/WSDL)


OntoBroker ha s a Web s ervi ce i nterfa ce for s ubmi tti ng queri es a nd comma nds . It a l s o a l l ows you to a dd or
remove mul ti pl e fa cts i n a s i ngl e ca l l . The Web s ervi ce i nterfa ce i s a cti va ted by s ta rti ng the s ta nda l one
OntoBroker s erver wi th the »-webs ervi ce« comma nd l i ne opti on. Thi s des cri pti on wi l l gi ve a s hort overvi ew of
the s upported fea tures . It i s not i ntended to gi ve a n i mpl ementa ti on overvi ew.

Usage of Web service in the Standalone Server


In thi s ca s e, the Web s ervi ce i s jus t a nother protocol for s ubmi tti ng queri es a nd comma nds . For more deta i l s ,
s ee the "Sta nda l one Depl oyment" cha pter.

12.3.1 Webservice Interface

12.3.1.1 Web Service Operations


The OntoBroker web s ervi ce provi des s i x opera ti ons :
query - Us e thi s opera ti on to run ObjectLogi c or SPARQL queri es
command - Us e thi s opera ti on to s end comma nds to the OntoBroker s erver
queryBatch - Speci a l opera ti on to s end mul ti pl e queri es i n a s i ngl e mes s a ge to OntoBroker
openQuery - Sta rts eva l ua ti on of query a nd returns the query key
getNextQueryResults - Retri eves the next res ul ts
cancelOpenQuery - Ca l l thi s opera ti on to ca ncel a n open query

12.3.1.2 Details on Query Input and Output


The "query" opera ti on ha s two i nput pa ra meters . Wi th the "query" pa ra meter you provi de the query text of the
ObjectLogi c or SPARQL query. Wi th the "ful l xml " pa ra meter you s peci fy i n whi ch forma t the res ul ts a re
returned.
If ful l xml i s s et to fa l s e, onl y the ObjectLogi c repres enta ti on of the terms i s returned, i .e. onl y the "repr" fi el d
l i s t of "Ws Tupl e" i s fi l l ed. If ful l xml i s s et to true, the terms a re returned wi th thei r compl ete s tructure. In thi s
ca s e, onl y the "term" fi el d l i s t of "Ws Tupl e" i s fi l l ed.

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

With fullxml = false

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

With fullxml = true

<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>/

12.3.3 Load Balancing for Web Services


OntoBroker s upports the AJP protocol to ena bl e l oa d ba l a nci ng wi th the Apa che HTTP Server 2.2.
1. Ins ta l l Apa che HTTP Server 2.2.
2. Edi t <APACHE_HOME>/conf/httpd.conf
a) Ena bl e mod_proxy, mod_proxy_a jp, a nd mod_proxy_ba l a ncer.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
b) Set up your cl us ter.
ProxyPass / balancer://mycluster/

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

12.3.4 Paging Support for Web Service


The OntoBroker Web s ervi ce now ha s s upport for pa gi ng through the res ul ts of a query. Thi s i s us eful i f you
wa nt to proces s l a rge res ul t s ets i n s ma l l er pi eces .
There a re three opera ti ons i n the OntoBroker Web s ervi ce:

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 .

12.3.5 Extensions Directory to Deploy Web Services


To a dd a Web s ervi ce to OntoBroker, you s i mpl y i mpl ement the norma l JAX-WS webs ervi ce cl a s s whi ch
i mpl ements the ma rker i nterfa ce OntoBrokerServi ce a nd publ i s hes i t a s a n OntoBrokerServi ce to OSGI.
package com.ontoprise.ontobroker.webservice;

/**
* Marker interface for web services deployed together with OntoBroker
*/
@ExcludeAll
public interface OntoBrokerService {
}

The s kel eton of your Web s ervi ce cl a s s wi l l l ook l i ke thi s :


package com.acme.mywebservice

@javax.jws.WebService(endpointInterface ="com.acme.mywebservice.MyItf")
public class MyService implements MyItf, OntoBrokerService {
private OntologyManager _ontologyManager;

protected void bindOntoBrokerServiceManager(OntoBrokerServiceManager manager) {


_ontologyManager = manager.getOntologyManager();
}

// web service operations are added here


}

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

Dynamic Web Services


Dyna mi c Web s ervi ces a re onl y genera ted a utoma ti ca l l y from OntoStudi o or wi th the OntoBroker comma nd
genera teDyna mi cSvc.

12.4 How to Access OntoBroker From Other Programming Languages


12.4.1 Web Service Interface
To a cces s OntoBroker from the Web s ervi ce i nterfa ce, you fi rs t need the concrete URL for the OntoBroker WSDL.
If OntoBroker runs a s s ta nda l one s erver wi th the comma nd l i ne opti on -webs ervi ce, the URL i s
http://<ontobrokerhost>:<wsport>/services/ontobroker?wsdl
The defa ul t va l ue for <ws port> i s 8267. For more deta i l s on the correct URL s ee "Depl oyment s cena ri o 106 ".
The s a mpl es di rectory i nterfa ces \webs ervi ce conta i ns project a rchi ves for Vi s ua l Ba s i c, C#, Ja va , a nd Python.

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

12.4.2 Accessing Web Service with .NET


If you a re us i ng Vi s ua l Studi o, you ha ve to a dd a Web reference to your project before you ca n us e the
OntoBroker Web s ervi ce:
1. Cl i ck on the menu i tem Project of the ma i n menu a nd s el ect Add Service Reference....
2. Enter the URL of the WSDL a nd pres s the GO button.
The di a l og s houl d report "1 s ervi ce found".

3. Fi na l l y enter a na me for the reference a nd pres s the Add Reference button.


For other l a ngua ges or Web s ervi ce fra meworks s ee the documenta ti on i n order to unders ta nd how to bui l d/
genera te a Web s ervi ce cl i ent s ta rti ng wi th a WSDL.
The fol l owi ng exa mpl e s hows how to a cces s OntoBroker from C#. The s a mpl es di rectory i nterfa ces \webs ervi ce
conta i ns compl ete project a rchi ves for Vi s ua l Ba s i c a nd C#. You ca n us e thes e projects di rectl y wi th Mi cros oft
Vi s ua l Studi o 2008 or Mi cros oft Vi s ua l Studi o Expres s Edi ti ons .

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 + ".";

// add some facts to the module http://sample.ontoprise.de/ws


String msg;
msg = client.command("insert Michael[age->15]" + suffix);
Console.Out.WriteLine(msg);
msg = client.command("insert John[age->18]" + suffix);
Console.Out.WriteLine(msg);

109
OntoBroker 6.3 Interfa ces to OntoBroker

msg = client.command("insert Sandra[age->21]" + suffix);


Console.Out.WriteLine(msg);

// add a rule to the module http://sample.ontoprise.de/ws


string rule = "@{adult} ?P:Adult :- ?P[age->?X], ?X >= 18.";
// remove it first (only done here to allow multiple runs of this sample)
msg = client.command(":- module " + module + ".\ndelete rule adult.");
Console.Out.WriteLine(msg);
// really add the rule
msg = client.command(":- module " + module + ".\ninsert {" + rule + "}");
Console.Out.WriteLine(msg);

// query for all adult persons


QueryResults results = client.query("?- ?P:Adult[age->?Age]@?M.", false);

Console.Out.WriteLine("Results returned: " + results.result.Length);


PrintResults(results);

Console.Out.WriteLine();
Console.Out.WriteLine("Same query with paging");
Console.Out.WriteLine();

// same query using paging


int timeout = 900; // query can be removed after 900 seconds = 15 min, if
client dies
long queryKey = client.openQuery("?- ?P:Adult[age->?Age]@?M.", false,
timeout);
int maxResults = 1; // maximum number of results to return
int maxWaitTime = 100; // maximum wait time for results on server side
bool finished = false;
while (!finished) {
PagedQueryResults pagedResults = client.getNextQueryResults(queryKey,
maxResults, maxWaitTime);
PrintResults(pagedResults);
finished = pagedResults.finished;
}

Console.Out.WriteLine("Press any key");


Console.In.Read();
}

private static void PrintResults(QueryResults results)


{
foreach (WsTuple tuple in results.result)
{
for (int i = 0; i < results.variableNames.Length; i++)
{
if (i > 0)
Console.Out.Write(", ");
Console.Out.Write(results.variableNames[i] + " = " + tuple.repr
[i]);
}
Console.Out.WriteLine();
}
}
}
}

12.4.3 Accessing Web Service with Java


Bel ow you ca n s ee how to a cces s the OntoBroker Web s ervi ce wi th JAX-WS. If you a re us i ng Ja va 1.6, nothi ng
needs to be i ns ta l l ed, a s JAX-WS i s pa rt of Ja va Vers i on 6 (Sta nda rd Edi ti on). If you a re us i ng Ja va 1.5, you
need to i ns ta l l JAX-WS s epa ra tel y. There a re a l s o other web s ervi ce s ta cks a va i l a bl e for Ja va whi ch work
s i mi l a rl y. Ja va 1.6 a l l ows ea s y us a ge of Web s ervi ces a fter genera ti on of the cl i ent code. Thi s i s done by
ca l l i ng the ws i mport tool of Ja va :

110
OntoBroker 6.3 Interfa ces to OntoBroker

wsimport -d <classes> [-s <source>] http://<ontobrokerhost>:<wsport>/services/


ontobroker?wsdl
After thi s ca l l , the genera ted ja va cl a s s es a re wri tten to the <cl a s s es > di rectory, thei r s ource code opti ona l l y
to the di rectory <s ource>. If you i ncl ude thes e genera ted cl a s s es to your code, you ca n s ta rt worki ng wi th
OntoBroker. The fol l owi ng s a mpl e code s hows how to perform comma nds a nd queri es .
The s a mpl es di rectory i nterfa ces \webs ervi ce conta i ns a compl ete project a rchi ve whi ch ca n be us ed di rectl y
wi th Ecl i ps e 3.5 a nd l a ter.

/*
* 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 {

public static void main(String[] args) throws Exception {


OntobrokerType client = new OntobrokerSvcService().getOntobrokerSvcPort();

String module = "<http://sample.ontoprise.de/ws>";


String suffix = "@" + module + ".";

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

// add a rule to the module http://sample.ontoprise.de/ws


String rule = "@{adult} ?P:Adult :- ?P[age->?X], ?X >= 18.";
// remove it first (only done here to allow multiple runs of this sample)
msg = client.command(":- module " + module + ".\ndelete rule adult.");
System.out.println(msg);
// really add the rule
msg = client.command(":- module " + module + ".\ninsert {" + rule + "}");
System.out.println(msg);

// query for all adult persons


QueryResults results = client.query("?- ?P:Adult[age->?Age]@?M.", false);

System.out.println("Results returned: " + results.getResult().size());


printResults(results);

System.out.println();
System.out.println("Same query with paging");
System.out.println();

// same query using paging


int timeout = 900; // query can be removed after 900 seconds = 15 min, if
client dies
long queryKey = client.openQuery("?- ?P:Adult[age->?Age]@?M.", false,
timeout);

111
OntoBroker 6.3 Interfa ces to OntoBroker

int maxResults = 1; // maximum number of results to return


int maxWaitTime = 100; // maximum wait time for results on server side
boolean finished = false;
while (!finished) {
PagedQueryResults pagedResults = client.getNextQueryResults(queryKey,
maxResults, maxWaitTime);
printResults(pagedResults);
finished = pagedResults.isFinished();
}

System.out.println("Press any key");


System.in.read();
}

private static void printResults(QueryResults results) {


for (WsTuple tuple : results.getResult()) {
final List<String> variableNames = results.getVariableNames().getVar();
for (int i = 0; i < variableNames.size(); i++) {
if (i > 0)
System.out.print(", ");
System.out.print(variableNames.get(i) + " = " + tuple.getRepr().get
(i));
}
System.out.println();
}
}
}

12.5 Using the Extension API to Develop OntoBroker Extensions


Bui l t-i ns a nd rewri ters ma y be devel oped to extend the ca pa bi l i ti es of OntoBroker. They a l l ow devel opi ng
a cces s functi ons to a rbi tra ry s ys tems , to devel op a ny functi on needed or to i ntroduce a ddi ti ona l da ta i nto the
i nferenci ng proces s . The ba s i c a rchi tecture of the i nference engi ne i s a s ys tem gra ph. In thi s gra ph, tupl es
fl ow from one vertex to the other verti ces . A bui l t-i n i s s uch a vertex. Thi s mea ns tha t i t recei ves tupl es ,
compl etes them a nd s ends a wa y the compl eted tupl es .

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 .

12.5.1 Developing Your Own Built-ins

12.5.1.1 Making New Built-ins Known to OntoBroker


Ma ke s ure tha t your new bui l t-i n does not ha ve the s a me na me a s a n a l rea dy exi s ti ng one. You wi l l fi nd
exa mpl e bui l t-i ns i n the di rectory
interfaces/development/Code Examples
Thi s di rectory conta i ns a rea dy-to-us e Ecl i ps e project whi ch i ncl udes s ome exa mpl es .

12.5.1.2 Extensions Directory for Deploying Builtins


It i s pos s i bl e to pa cka ge one or mul ti pl e bui l ti ns i n a n OSGI bundl e. The bundl e mus t regi s ter a
Bui l ti nProvi der s ervi ce to a nnounce i ts bui l ti n contri buti ons to OntoBroker. Mos t s i mpl y, a decl a ra ti ve s ervi ce
i n OSGI ca n be us ed for thi s purpos e.
The Bui l ti nProvi der i nterfa ce ha s one s i ngl e method to return the bui l ti n cl a s s es of thi s extens i on bundl e.
package com.ontoprise.ontobroker.kernel.builtinsystem;

public interface BuiltinProvider {


Collection<Class<? extends IBuiltin>> getBuiltins();

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;

public class MyBuiltinsProvider implements BuiltinProvider {


@Override
public Collection<Class<? extends IBuiltin>> getBuiltins() {
ArrayList<Class<? extends IBuiltin>> list = new ArrayList<Class<? extends
IBuiltin>>();
list.add(MyBuiltin.class);
return list;
}

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

12.5.1.3 Writing a Built-in for OntoBroker 6


Externa l bui l ti ns for OntoBroker mus t be pa cka ged a s a n OSGi bundl e. The bundl e ha s to provi de a
Bui l ti nProvi der s ervi ce to a nnounce i ts bui l t-i ns . After s etti ng up the envi ronment i n Ecl i ps e, you crea te your
own bui l t-i n project i n the fol l owi ng wa y:
1. Ecl i ps e Ma i n menu File -> New -> Other… -> Plugin-Project.

113
OntoBroker 6.3 Interfa ces to OntoBroker

2. Ens ure to check an OSGi framework i n the Ta rget Pl a tform group.


3. Pres s Next.

114
OntoBroker 6.3 Interfa ces to OntoBroker

4. Dea cti va te Generate an activator.


5. Pres s Next.

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.

10. Pres s the Add… button of the requi red pl ug-i ns a nd a dd


com.ontoprise.ontobroker.base
com.ontoprise.ontobroker.datamodel
11. Pres s the Add… button of Imported Pa cka ges a nd a dd org.apache.log4j.
12. Sa ve the cha nges .
13. Add the fol l owi ng cl a s s es : com.acme.sample.ConcatBuiltin.java.

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]);

System.out.println("str1=" + str1 + ", str2=" + str2);


if (str1 == null || str2 == null)
return false; // input parameters cannot be converted to
strings

String s = str1 + str2;


Term result = KAON2Manager.factory().constantString(s);

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;
}
}

Declare the service


1. Add the fol der "OSGI-INF" to the project.
2. Sel ect the fol der a nd choos e from the context menu New -> Component Definition.
3. Fi l l the wi za rd.

119
OntoBroker 6.3 Interfa ces to OntoBroker

4. Sel ect the ta b Services a nd a dd to Provi ded Servi ces : com.ontoprise.ontobroker.kernel.


builtinsystem.BuiltinProvider

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

Use the built-in


Copy thi s ja r fi l e to the OntoBroker extens i ons di rectory to us e the bui l t-i n.
On a ddi ng the ja r fi l e to the extens i ons di rectory you s houl d s ee fol l owi ng mes s a ge i n the l og:
INFO [CONFIG] Bui l ti n a dded: obl :res erved:myconca t/3
Run fol l owi ng query:
?- _myconcat("ab", "cd", ?X).
You s houl d get a s res ul t:
?X = "abcd"

12.5.1.4 The IsNumber Example Built-in


Al l bui l t-i ns ha ve to i mpl ement one of the fol l owi ng i nterfa ces : IFi l terBui l ti n, IFuncti ona l Bui l ti n,
IRel a ti ona l Bui l ti n a nd IConnector. Thes e a re di fferent s ubcl a s s es of bui l t-i ns . The fi l ter bui l t-i ns jus t a ccept
ground i nput tupl es a nd return ei ther true – i f i t ma tches the i mpl emented fi l ter, or fa l s e otherwi s e. The
functi ona l bui l t-i ns ma y return none or one s i ngl e res ul t, the rel a ti ona l bui l t-i ns ma y return none, one or
s evera l res ul ts . The connector bui l t-i ns a re us ed to get da ta from externa l s ources . A rel a ti ona l bui l t-i n

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

// Only return true if the condition matches.


return true;
}
} catch (ClassCastException e) { // This exception cannot be thrown, as
BuiltinServices.isNumber does a check.
System.out.println("invalid parameters", e); // However, any error should
be logged, no exception should be thrown just of invalid input.
}
return false; // Default return value for all non-matching input.
}

/**
* 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

* 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 {
return grounds.getBitSet().get(0); // The one argument this built-in needs
has to be ground
}

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;

public class Square implements IRelationalBuiltin {


protected static Logger _log = Logger.getLogger(OntopriseConstants.CORE_LOG);

/**
* 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

public void evaluate(Term[] input, IGrounds grounds, IReceiver destination)


throws KAON2Exception, InterruptedException {
try {
switch (grounds.getInt()) {
case 3: {
if (!(((Constant) input[0]).getValue() instanceof Double) || !
(((Constant) input[1]).getValue() instanceof Double)) {
}
double op1 = ((Double) ((Constant) input[0]).getValue()).
doubleValue();
double result = ((Double) ((Constant) input[1]).getValue()).
doubleValue();
if (op1 * op1 == result) {
destination.send(input); // sends the result away. The input
Term[] is used as buffer.
}
break;
}
case 1: {
if (!(((Constant) input[0]).getValue() instanceof Double)) {
}
double op1 = ((Double) ((Constant) input[0]).getValue()).
doubleValue();
double result = op1 * op1;
input[1] = KAON2Manager.factory().constant(new Double(result));
destination.send(input); // sends the result away. The input Term
[] is used as buffer.
break;
}
case 2: {
if (!(((Constant) input[1]).getValue() instanceof Double)) {
}
double op2 = ((Double) ((Constant) input[1]).getValue()).
doubleValue();
double result = Math.sqrt(op2);
input[0] = KAON2Manager.factory().constant(new Double(result));
destination.send(input); // sends the result away. The input Term
[] is used as buffer.
input[0] = KAON2Manager.factory().constant(new Double(result * -
1)); // just write the second result into the buffer, overwriting the first result.
destination.send(input); // sends the result away. The input Term
[] is used as buffer.
break;
}
default:
}
} catch (ClassCastException e) { // catch exception for wrong input values.
This is logical handled as false.
_log.error("invalid input", e);
}
}

/**
* 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

// 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, "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

case 3: // both arguments are ground, binary: 11


return true;
default:
return false; // cannot be evaluated
}
}

12.5.1.5 The Multiply Example Built-in


The terna ry bui l t-i n mul ti pl y ta kes two numbers (the fi rs t two a rguments ) mul ti pl i es them a nd returns the
res ul t i n the thi rd a rgument. In a ddi ti on to the other exa mpl es a new res ul ti ng a tom mus t be genera ted
whi ch returns the res ul t. Thi s bui l t-i n ha s three a rguments a nd ha s the s tri ng repres enta ti on <mul ti pl y> i n
ObjectLogi c progra ms :

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

// 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; // return true to signal there is a result in
the buffer
}
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); // write the result into the buffer
return true; // return true to signal there is a result in the
buffer
}
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[2]);
// third argument must be filled with the result
result = op2 / op1;
// Create and send away the new tuple.
input[1] =
KAON2Manager.factory().constantDouble(result); // write the result into the buffer
return true; // return true to signal there is a result in the
buffer
}
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); // write the result into the buffer
return true; // return true to signal there is a result in the
buffer
}
}
} catch (Exception e) {
_log.error("Invalid input", e);// catch exception for wrong input values.
This is logical handled as false.
}
return false; // return false to signal there no valid result in the buffer
}

/**
* 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
}
}

12.5.1.6 A Connector Built-in


A connector i s a bui l t-i n whi ch i s us ed to a cces s externa l s ervers (for exa mpl e, da ta ba s es , i ndexes , s ea rch
engi nes ).
Query of the ontol ogy:
?- p(?X) AND democonnector(?X,?Y).

How A Connector Works:


At fi rs t OntoBroker l ooks wha t va ri a bl es ha ve to be bound, free a nd whi ch va ri a bl es a re not i mporta nt for
bei ng eva l ua bl e. Then, i t a s ks the connector for the goodnes s of s ome of the pa tterns . It i s up to the
connector to i nterpret the goodnes s , i t coul d be the di fference of a ful l ta bl e s ca n a nd us i ng the pri ma ry key
of a da ta ba s e a cces s .
Then, the i ns ta nce of the connector for the eva l ua ti on i s crea ted, a nd i ni t i s ca l l ed. Sta rt i s ca l l ed, fol l owed
by s ome ca l l s for i nput. The connector coul d now s ta rt to work. If i t needs to ha ve a l l i nput tupl es , i t ha s to
s ta rt the eva l ua ti on when s top i s ca l l ed. The connector ha s to s end a l l da ta before l ea vi ng the s top method.
(So don't us e a s epa ra te threa d for i t.) After s top wa s ca l l ed, other s ta rt/i nput*/s top cycl es coul d occur.
eva l ua ti onFi ni s hed ma y pos s i bl e be ca l l ed a nd coul d be fol l owed from a repeti ti on of the eva l ua ti on, but
now s ta rted wi th s ta rt/i nput*/s top cycl es .

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

* @throws InterruptedException Is thrown on Interruption


*/
@Override
public void input(Term[] input) throws KAON2Exception, InterruptedException {
Term[] terms = new Term[input.length];
System.arraycopy(input, 0, terms, 0, input.length);
_input.add(terms);
}

/**
* 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

* Returns how effective these grounds may be evaluated. Should deliver 0 if it


does not matter.
* Like IBuiltin.isEvaluable() this method may be called before init() has been
called.
*
* @param grounds IGrounds object with grounding informations of all following
input tuples.
* @param builtinContext BuiltinContext with additional context informations
* @param args Literal arguments
* @return int with goodness value.
*/
@Override
public int getGoodness(IGrounds grounds, BuiltinContext builtinContext, Term[]
args) throws KAON2Exception, InterruptedException {
// this connector has just one possible binding, so just use a constant
number between 0 and 1000.
// 1000 should mean this connector is much faster than a connector with
goodness 0.
return 500;
}

/**
* 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

* @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 {
return grounds.getBitSet().get(0) && !grounds.getBitSet().get(1); // the
first argument must be ground, the second argument must not be ground.
}

12.5.1.7 Important Note for Datatype Conversions


Worki ng wi th type convers i ons ca n be tri cky. There a re a coupl e of probl ems tha t mi ght l ea d to unexpected
query res ul ts .

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

12.5.1.8 Important Note for Floating Point Operation


The <a d d > bui l t-i n del i vers non-whol e-numbered res ul ts .
Des cri pti on:
"?- 1.1[_add(?X)->16.1]." delivers X = 15.000000000000002, but
"?- 1.1[_add(?X)->15.1]." delivers X = 14.0.
The probl em wi th thi s i s tha t i t i s not OntoBroker-s peci fi c but rel a ted to fl oa ti ng poi nt opera ti ons i n genera l .
The error ca n s i mpl y be reproduced by thi s ja va code:
public static void main(String[] args) {
double op1 = 1.1;
double op2 = 15.1;
double result = op2 - op1;
System.out.println(op2+" - "+op1+" = "+result);
op2 = 16.1;
result = op2 - op1;
System.out.println(op2+" - "+op1+" = "+result);
The output wi l l be:
15.1 - 1.1 = 14.0
16.1 - 1.1 = 15.000000000000002
The poi nt i s tha t you a re forced to round/forma t your res ul t i f you us e fl oa ti ng poi nt numbers . You s houl d us e
the round/rounddi gi t bui l t-i ns to round the res ul t of the a dd-opera ti on to the des i red preci s i on.

138
OntoBroker 6.3 Interfa ces to OntoBroker

12.5.1.9 Important Note for Number Usage


We s upport i nteger numbers tha t a re 8 bytes s i gned (equi va l ent to Ja va 's l ong da ta type) a nd ra nges from:
-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807

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.

12.5.1.10 List of Possible Signature Types


None. Every bui l t-i n ha s to check thi s for i ts el f. If i nva l i d i nput i s del i vered, no excepti on s houl d be thrown
(but l og i t). The bui l t-i n i s jus t one method of rea l i zi ng a predi ca te, a nd i t s houl d be of no di fference i f you
us e bui l t-i ns or rul es or fa cts i n the edb. If the a rguments do not ma tch, the res ul t i s fa l s e.

12.5.1.11 List of Predefined Grounds


Found wi thi n i nterfa ce IGround.
FIFTH FOURTHFIFTH
FIRSTFIFTH FIRSTFOURTHFIFTH
SECONDFIFTH SECONDFOURTHFIFTH
FIRSTSECONDFIFTH FIRSTSECONDFOURTHFIFTH
THIRDFIFTH THIRDFOURTHFIFTH
FIRSTTHIRDFIFTH FIRSTTHIRDFOURTHFIFTH
SECONDTHIRDFIFTH SECONDTHIRDFOURTHFIFTH
FIRSTSECONDTHIRDFIFTH FIRSTSECONDTHIRDFOURTHFIFTH
Al l of thes e grounds defi ne a bi t vector whi ch des cri bes a ground a rgument by 1 a nd a va ri a bl e by 0. Ins tea d
of thes e na mes a n a ppropri a te bi t vector ca n be us ed. The vector i s rea d from ri ght to l eft; i ts l a s t bi t
des cri bes the fi rs t a rgument.

12.5.2 Developing Your Own Rewriters


When OntoBroker eva l ua tes a query, i t checks whi ch rul es a re rel eva nt for the query a nd then rewri tes the
rel eva nt rul es (e.g. for performa nce rea s ons ). It i s a l s o pos s i bl e to devel op your own rewri ters whi ch then a re
a ppl i ed duri ng the rea s oni ng proces s . The fol l owi ng exa mpl e rewri ter excha nges "l es s " bui l t-i ns wi th
"grea ter" bui l t-i ns (of cours e i t does n't ma ke a ny s ens e, but i t hel ps i l l us tra ti ng the power of rewri ters ):

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;

public class ExampleRuleRewriter extends 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

public Rule rewrite(Rule rule) throws DataModelException {


Rule result = rule;
if (containsLessLiterals(rule)) {
result = exchangeBodyByGreater(rule);
}
return result;
}

/**
* 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

Rule newRule = KAON2Manager.factory().rule(rule.getAxiomID(), rule.


getHeadLiterals(), rule.isHeadConjunctive(), newBodyLiterals);
return newRule;
}
}

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.

12.5.2.1 Extensions Directory for Deploying Rewriters


To a dd one or mul ti pl e rewri ters to OntoBroker, you need to publ i s h a IRewri terProvi der s ervi ce.
package com.ontoprise.api.rewriter;

public interface RewriterProvider {


List<RewriterSpec> getRewriterSpecs();
}

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 >

12.5.3 Extensions Directory for Deploying a Web Service


To a dd a Web s ervi ce to OntoBroker, you s i mpl y i mpl ement a norma l JAX-WS webs ervi ce cl a s s , whi ch
i mpl ements the ma rker i nterfa ce OntoBrokerServi ce, a nd publ i s h i t a s a n OntoBrokerServi ce to OSGI.
package com.ontoprise.ontobroker.webservice;

/**
* Marker interface for web services deployed together with OntoBroker
*/
@ExcludeAll
public interface OntoBrokerService {
}

The s kel eton of your Web s ervi ce cl a s s wi l l l ook l i ke thi s :


package com.acme.mywebservice

@javax.jws.WebService(endpointInterface ="com.acme.mywebservice.MyItf")
public class MyService implements MyItf, OntoBrokerService {
private OntologyManager _ontologyManager;

protected void bindOntoBrokerServiceManager(OntoBrokerServiceManager manager) {


_ontologyManager = manager.getOntologyManager();
}

// web service operations are added here


}

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

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

12.5.4 Use OntoBroker Examples


You ca n ea s i l y crea te cus tom Bui l t-i ns , comma nds , connectors , rewri ters or webs ervi ces wi th the Cus tomerIDE.
Got to
interfaces\development\com.ontoprise.ontobroker.examples.api\ReadMe.txt
Jus t fol l ow the s teps di s cri bed i n the Rea dMe.txt fi l 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

The ba s i c concept i s a pi pel i ne of three s ta ges .


1. Collection Reader - a col l ecti on rea der provi des i nforma ti on a s text. A s i mpl e col l ecti on rea der coul d jus t
rea d a text fi l e from the fi l e s ys tem a nd provi de the conta i ned text a s i t i s .
2. Analysis Engine - a n a na l ys i s engi ne proces s es the text provi ded by the col l ecti on rea der. It a nnota tes
pi eces of text to be a pa rti cul a r ki nd of i nforma ti on. As a n exa mpl e, a n a na l ys i s engi ne ma y s ca n the text
for phone numbers . The i nforma ti on i s s tored i n i ndexes .
3. Consumer - a cons umer a cces s es the s tructured i nforma ti on i n the i ndexes a nd proces s es them i n s ome
wa y. A typi ca l cons umer ma y s tore the i nforma ti on s omewhere, e.g. i n a da ta ba s e.

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

12.6.1 Semantic Content Analytics (SCA)


Na tura l l a ngua ge proces s i ng i s a l a rge fi el d wi th ma ny us eful a ppl i ca ti ons . OntoBroker provi des the
ca pa bi l i ty to go beyond norma l content a na l ys i s by a ddi ng s ema nti cs on top.
As a n exa mpl e, thi nk of a hos pi ta l wi th a n a ccounti ng center ha vi ng a n eye on i nvoi ces to a voi d a l os s of
money. The a mount a n i ns ura nce compa ny pa ys for a n opera ti on ma y depend on the ca us e of di s ea s e. Let's
s a y tha t the da ta s et for a pa rti cul a r opera ti on i ncl udes na tura l l a ngua ge i nforma ti on a bout the s ymptoms
a nd a l s o a di a gnos i s .
Now, for a concrete opera ti on, $1000 ca n be bi l l ed, i f A i s the ca us e of di s ea s e, whi l e for B a s ca us e of
di s ea s e, $2000 a re a l l owed. Sa dl y the di a gnos i s mi ght be uncl ea r or wrong. If the s ymptoms i ndi ca te A, but
the di a gnos i s i s B, the hos pi ta l woul d bi l l more tha n i t i s a l l owed to. On the other ha nd, i f the s ymptoms
i ndi ca te B but the di a gnos i s i s A, the hos pi ta l woul d l oos e money by not goi ng for B.
Thi s i s where s ema nti c content a na l yti cs comes i n. The s ymptoms a re ta ken from the na tura l l a ngua ge text.
Together wi th a n ontol ogy model i ng s ymptom, des cri pti ons a nd di a gnos i s , rea s oni ng ca n then be us ed to
deri ve the mos t l i kel y ca us e of di s ea s e or to check for i ncons i s tenci es .

12.6.1.1 Using OntoBroker as CAS Consumer


OntoBroker provi des a n UIMA CAS cons umer whi ch i tera tes over the da ta i n the UIMA i ndexes a nd pus hes i t to
a n OntoBroker Col l a b Server. Fea tures a re ma pped to ObjectLogi c concepts , fea ture types to properti es of the
rel a ted concepts . For a n entry i n a n UIMA i ndex of a pa rti cul a r type, a new i ns ta nce of the concept
corres pondi ng to the type i s crea ted. The cons umer a l l ows the fi l teri ng of pa rti cul a r types or fea tures . For
more i nforma ti on, s ee the rel a ted pa ra meter des cri pti ons i n the des cri ptor fi l es of the cons umer.

12.6.1.2 CAS Consumer Deployment


The OntoBroker i ns ta l l a ti on conta i ns a s cri pt under
<OntoBroker Installation Folder>/interfaces/uima
whi ch crea tes a UIMA pea r fi l e i ncl udi ng the CAS cons umer. The pea r fi l e i ncl udes both, a CAS Cons umer a nd
a n Ana l ys i s Engi ne des cri ptor fi l e. The pea r fi l e ca n be i ns ta l l ed us i ng a pea r i ns ta l l er tool or i t ca n be us ed
di rectl y from wi thi n a thi rd pa rty a ppl i ca ti on s upporti ng UIMA. Pl ea s e s ee your thi rd pa rty a ppl i ca ti on
documenta ti on for more i nforma ti on.
The OntoBroker CAS cons umer i s currentl y ba s ed on Apa che UIMA vers i on 2.2.2.

12.6.1.3 Importing UIMA Facts into a Domain Ontology


Us ua l l y the types a nd fea tures us ed by the a nnota tors wi l l not di rectl y ma p to the voca bul a ry of a doma i n
ontol ogy. If a rena mi ng of concepts i s s uffi ci ent, you ma y us e the OntoStudi o ma ppi ng tool to ma p the UIMA-
rel a ted concepts to the concepts i n the doma i n ontol ogy. For more a dva nced ma ppi ngs , rul es ma y be us ed.
An i mport s tructure for the i nvol ved ontol ogi es ma y l ook l i ke thi s :
Domain ontology
|- Mapping ontology - including mapping rules
|- UIMA facts ontology - containing the facts from the consumer

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 .

13.1 Role-Based Security


Rol e-ba s ed s ecuri ty a l l ows you to s peci fy us ers , thei r rol es a nd thei r permi s s i ons i n a s ecuri ty ontol ogy.

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

13.3 Module Permissions


We ha ve three types of modul e permi s s i ons :
Rea d permi s s i on (ha s Rea dPermi s s i on)
Wri te permi s s i on (ha s Wri tePermi s s i on)
Tempora ry wri te permi s s i on (ha s TempWri tePermi s s i on)
When a us er ha s rea d permi s s i on he i s a l l owed to rea d a l l of the fa cts from the corres pondi ng modul e a nd
he ca n us e rul es wi th body formul a s whi ch a cces s the modul e.
Wri te permi s s i on gra nts a us er wri te a cces s to a modul e. Thi s a l s o mea ns tha t the us er i s a l l owed to us e
rul es wi th hea d formul a s whi ch a cces s the corres pondi ng modul e.
Tempora ry wri te permi s s i on for a modul e mea ns tha t the us er i s not a l l owed to cha nge fa cts of the modul e,
but i t i s pos s i bl e to execute queri es wi th tempora ry fa cts whi ch a dd new fa cts a nd rul es for the dura ti on of
the query.

Important note for ontology imports:


Us er U ha s r-ri ghts for ontol ogy A whi ch i mports ontol ogy B -> no "i nheri ted" ri ghts for ontol ogy B.

13.4 Property Permissions


As for modul es , there a re three di fferent permi s s i ons for properti es
Rea d permi s s i on (ha s PropertyRea dPermi s s i on)
Wri te permi s s i on (ha s PropertyWri tePermi s s i on)
Tempora ry wri te permi s s i on (ha s PropertyTempWri tePermi s s i on)
Permi s s i ons for properti es a re onl y a cti va ted i f thes e three s wi tches i n the OntoConfig.prp a re a l l
a cti va ted:
Security.LoginRequired = on
Security.AccessControl = on
Security.PropertyAccessControl = on
In thi s ca s e, the us ers need rea d a cces s for every s i ngl e property they a re us i ng.

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"].

@{rule1} ?X[name2->?Y] :- ?X[name->?Y].


You ca n defi ne rol es wi th a s et of property permi s s i ons i n the $s ecuri ty.obl :
role1:Role[hasPropertyReadPermission-> <http://company.com/name>,
hasPropertyTempWritePermission-> <http://company.com/name>,
hasPropertyWritePermission-> <http://company.com/name>,
hasPropertyReadPermission-> <http://company.com/name2>
].

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>

?- _isPropertyPermitted(<http://company.com/name>, write). // check write


permissions

?- _isPropertyPermitted(<http://company.com/name>, temp_write). // check write


permission for temporary facts and rules

13.5 Basic Configuration


The s ecuri ty confi gura ti on cons i s ts of three pa rts :
1. The OntoConfi g.prp.
2. The s ecuri ty modul e.
3. The s ecuri ty context.
Fi rs t we confi gure the OntoConfi g.prp: In order to turn on the a cces s control you ha ve to s et two s wi tches
Security.AccessControl = on
Security.LoginRequired = on
a nd the pa th to the other confi gura ti on fi l es (thi s i s opti ona l , per defa ul t the "conf" fol der i s us ed):
dir.conf = /home/projects/someProject/conf

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 )

Authentication via webconsole


When a uthenti ca ti on i s s wi tched on, then the webcons ol e s hows you a di a l og whi ch a l l ows you to s peci fy
your us erna me a nd pa s s word. After the l ogi n the webcons ol e a utoma ti ca l l y ha ndl es the ha ndl i ng wi th
ti ckets .

Authentication from commandline


If you work from the comma ndl i ne then you ha ve to s peci fy the us er na me a nd the pa s s word for ea ch
comma nd. The fol l owi ng exa mpl es a s s ume tha t the us er na me i s 'root' a nd the pa s s word 'open4me'. Execute
the "i s a l i ve" comma nd:
c:\test>command.cmd -l root:open4me isalive
[INFO]: Inference Server on port 2267 is up and running ...
Execute a query:
c:\test>query.cmd -l root:open4me "?-?X::Y@M."
["X","Y","M"],
[SomeSubConcept,SuperConcept,m1],

146
OntoBroker 6.3 Rol e-Ba s ed Securi ty

13.7 Configuration of the Security Context


The "conf" fol der conta i ns a fi l e "s ecuri ty-context.xml ". Thi s confi gura ti on fi l e a l l ows the s peci fi ca ti on of the
rea l ms whi ch s houl d be us ed a nd the a uthenti ca ti on s tra tegy.

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.

Security Module Realm


The s ecuri ty-context.xml fi l e for the s ecuri ty modul e rea l m i s
<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"/>
<ref local="SecurityModuleRealm"/>
</list>
</property>
<property name="authenticationStrategy">
<bean class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"/>
</property>

</bean>

<bean id="SecurityModuleRealm" class="com.ontoprise.security.realm.


SecurityModuleAuthorizationRealm"> </bean>
<bean id="PropertiesRealm" class="com.ontoprise.security.realm.PropertiesRealm">
<property name="resourcePath"><value>conf/security.properties</value></property> </
bean> </beans> </source>

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

13.8 Modeling the Security Module Realm with OntoStudio


It i s pos s i bl e to edi t the s ecuri ty ontol ogy rea l m (whi ch i s ObjectLogi c ba s ed) di rectl y wi th OntoStudi o. The
s chema of the s ecuri ty ontol ogy i s defi ned i n $s ecuri ty-core.obl (whi ch i s per defa ul t i n the "conf" di rectory). If
you wa nt to be a bl e to edi t the s ecuri ty ontol ogy vi a OntoStudi o you ha ve to i mport the s chema ontol ogy. E.g.

:- module = '$security'.
:-prefix = "http://ontoprise.de/".
:-import = '$security-core'.

demo:User[hasRole->{m1all,m2read,foo}].
root:User[hasRole->allModules].

m1all:Role[hasReadPermission->m1; hasTempWritePermission->m1; hasWritePermission-


>m1].

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

// Concept hierarchy ------------------------------------

Module[].
Role[].
User[].

Role[hasReadPermission {0:*} *=> Module].


Role[hasWritePermission {0:*} *=> Module].
Role[hasTempWritePermission {0:*} *=> Module].
Role[hasPermission {0:*} *=> WildcardPermission].
User[hasRole {0:*} *=> Role].

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

The mos t i mporta nt concepts a re:


Us er (a us er ca n ha ve mul ti pl e rol es )
Rol e (a rul e cons i s ts of zero or more permi s s i ons )
Modul e (known modul es a re i ns ta nces of thi s concept)

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:

<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="ActiveDirectory"/>
<ref local="PropertiesRealm"/>
<ref local="SecurityModuleRealm"/>
</list>
</property>
<property name="authenticationStrategy">
<bean class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"/>

149
OntoBroker 6.3 Rol e-Ba s ed Securi ty

</property>

</bean>

<bean id="SecurityModuleRealm" class="com.ontoprise.security.realm.


SecurityModuleAuthorizationRealm">
</bean>
<bean id="ActiveDirectory" class="org.apache.shiro.realm.
activedirectory.ActiveDirectoryRealm">
<property name="ldapContextFactory">
<bean class="org.apache.shiro.realm.ldap.DefaultLdapContextFactory">
<property name="searchBase">
<value>dc=ads,dc=yourcompany,dc=com</value>
</property>
<property name="systemUsername">
<value>admin</value>
</property>
<property name="systemPassword">
<value>pass</value>
</property>
<property name="principalSuffix">
<value>@ads.yourcompany.com</value>
</property>
<property name="url"><value>ldap://ads1.yourcompany.com:389/</value>
</property>
</bean>
</property>
<property name="searchBase">
<value>DC=ads,DC=yourcompany,DC=com</value>
</property>
<property name="principalSuffix">
<value>@ads.yourcompany.com</value>
</property>
<property name="groupRolesMap">
<map>
<entry key="CN=group1,OU=Karlsruhe,DC=ads,DC=yourcompany,DC=com" value="role1"/>
<entry key="CN=group2,OU=Karlsruhe,DC=ads,DC=yourcompany,DC=com" value="role2"/>
</map>
</property>
</bean>
<bean id="PropertiesRealm" class="com.ontoprise.security.realm.PropertiesRealm">
<property name="resourcePath">
<value>conf/security.properties</value>
</property>
</bean>
</beans>
</source>

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

rol es , e.g. rol es defi ned i n ObjectLogi c a re not cons i dered.

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

13.10 Access Restrictions for Commands


It i s a l s o pos s i bl e to res tri ct the OntoBroker s erver comma nds . For exa mpl e, the comma nd "s hutdown" s houl d
onl y be executed by a n a dmi ni s tra tor.

OntoBroker Commands Via Property File Realm


In thi s ca s e you ca n put i nto your "s ecuri ty.properti es " fi l e s omethi ng l i ke
user.Joe = pwd_joe, manager
user.Jane = pwd_jane, powerUser

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.

OntoBroker Commands Via Security Module Realm


The a cces s ri ghts confi gura ti on of comma nds ca n a l s o be confi gured wi th the s ecuri ty modul e rea l m. In thi s
ca s e the s ecuri ty ontol ogy for the s cena ri o a bove i s
:- module = $security.
:- importmodule $'security-core'.

... // similar as above

// 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.11 Support for multiple principalSuffix in ActiveDirectory


The "us erPri nci pa l Na me" a ttri bute i s us ed for l ogi n a nd queryi ng us er rol es . It i s bui l t by conca ti ng us erna me
a nd a pri nci pa l Suffi x. La rge Acti veDi rectory i ns ta l l a ti ons ma y us e mul ti pl e us er pri nci pa l na me s uffi ces . For s uch
s cena ri os , OntoBroker 6.3 now s upports a l i s t of us er pri nci pa l na me s uffi ces . In thi s ca s e, the confi gura ti on for
the Acti veDi rectory rea l m ma y l ook l i ke thi s :

<bean id="ActiveDirectory" class="com.ontoprise.security.realm.ActiveDirectoryExRealm


">
<property name="ldapContextFactory">
<bean class="com.ontoprise.security.realm.AdLdapContextFactory">
<property name="searchBase"><value>dc=mycompany,dc=com</value></property
>
<property name="systemUsername"><value>admin</value></property>
<property name="systemPassword"><value>admin</value></property>
<property name="principalSuffixList">
<list>
<value>@ads.mycompany.com</value>
<value>@ads2.mycompany.com</value>
</list>
</property>
<property name="url"><value>ldap://domaincontroller.mycompany.com:389/</
value></property>
</bean>
</property>
<!-- search base for groups -->
<property name="searchBase"><value>OU=Karlsruhe,DC=ads,DC=mycompany,DC=com</
value></property>
<property name="groupRolesMap"><map>
<entry key="CN=group1,OU=Karlsruhe,DC=ads,DC=mycompany,DC=com" value="group1
"/>
<entry key="CN=group2,OU=Karlsruhe,DC=ads,DC=mycompany,DC=com" value="group2
"/>
</map></property>
</bean>

13.12 Other Access Restrictions


As a defa ul t i t i s no l onger pos s i bl e to us e query opti ons l i ke "tra ce". But i t i s pos s i bl e to gi ve s ome rol es the
a ppropri a te a cces s ri ghts .
Joe:User[hasRole->m1all,debug].
debug:Role[hasPermission->'ob:reasoner:debug'].
Thi s s ecuri ty ontol ogy s peci fi es tha t the us er "Joe" ha s the ri ghts to us e debuggi ng query opti ons (e.g.
"tra ce").

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:comma nd:query Permi s s i on hol der i s a l l owed to perform query comma nd

Permi s s i on hol der i s a l l owed to perform comma nd na med "xy". xy i s


a pl a cehol der
ob:comma nd:xy
here for a ny of the OntoBroker comma nds l i ke query, i ns ert,
del ete, ...

ob:comma nd:* Permi s s i on hol der i s a l l owed to perform a ny comma nd

Permi s s i on hol der i s a l l owed to ca l l method Ontol ogyMa na ger.


ob:col l a bs erver:ca ncel pendi ngopen ca ncel Pendi ngOpen()
vi a Col l a bs erver

Permi s s i on hol der i s a l l owed to s ta rt l ong tra ns a cti ons vi a


ob:col l a bs erver:l ongtra ns a cti on
Col l a bs erver

Permi s s i on hol der i s a l l owed to ca l l method


ob:col l a bs erver:s es s i oni nfo Cl i entSes s i onMa na ger.getActi ve
() vi a Col l a bs erver

Permi s s i on hol der i s a l l owed to l oa d or crea te a ny new ontol ogy vi a


ob:col l a bs erver:a ddontol ogy
Col l a bs erver

ob:col l a bs erver:* Permi s s i on hol der ha s a l l col l a bs erver permi s s i ons

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

ob:rea s oner:* Permi s s i on hol der ha s a l l rea s oner permi s s i ons

Log User Login/Logout


Thi s fea ture wi l l do the fol l owi ng: If (a nd onl y i f) the fol l owi ng l i ne i n conf/l og4j.properti es
log4j.category.[LOGIN]=WARN
i s cha nged to
log4j.category.[LOGIN]=INFO
then a us er l ogi n/l ogout i s l ogged. Thi s fea ture onl y ma kes s ens e when the s erver i s s ta rted wi th
Security.LoginRequired = 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 .

13.13.1 Custom Permissions


You ca n defi ne a nd us e cus tom permi s s i ons on modul e l evel a s fol l ows :
1. Add defi ni ti ons of cus tom permi s s i ons to the security-context.xml.
Add a property cus tomPermi s s i onDefi ni ti ons to the bea n Securi tyModul eRea l m i n s ecuri ty-context.xml .
Exa mpl e:
<bean id="SecurityModuleRealm"
class="com.ontoprise.security.realm.SecurityModuleAuthorizationRealm">
<property name="customPermissionDefinitions">
<list>
<value>deploy</value>
<value>undeploy</value>

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

13.14 Terminology Glossary


A s hort overvi ew of the termi nol ogy. To us e a dva nced fea tures of Apa che Ki you s houl d be fa mi l i a r wi th s ome
of the termi nol ogy.

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

A s ubject repres ents a n us er wi th a l l hi s rol es a nd permi s s i ons .

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

Informa ti on whi ch i s us ed to veri fy the i denti ty of a us er.

Permi s s i on

The a bi l i ty to perform a n a cti on. In OntoBroker permi s s i ons coul d be


Rea d a cces s to a modul e
Wri te a cces s to a modul e
Comma nd executi on a cces s
OntoBroker a l s o a l l ows wi l dca rd permi s s i ons for s ome fea tures . For exa mpl e, you ca n us e '*' a s a
wi l dca rd to s peci fy modul es :
Joe:Us er[ha s Rol e-> Res ea rchAndDevel opmentMember].
Res ea rchAndDevel opmentMember:Rol e[ha s Rea dPermi s s i on->*].
It i s a l s o pos s i bl e to us e wi l dca rd permi s s i ons for comma nd executi ons :
rol e.a dmi n = ob:comma nd:*
Ins tea d of s peci fyi ng a l i s t of a l l owed comma nds we gra nt the "a dmi n" rol e a cces s to a l l comma nds .

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.

14.1 Configuration GUI


OntoBroker offers you a n ea s y to us e confi gura ti on i nterfa ce. Sta rt OntoBroker a nd cl i ck on "Confi gure". The
confi gura ti on GUI a ppea rs . Every new confi gura ti on ca n be s a ved. Si mpl e choos e Save a nd your cus tom
confi gura ti on wi l l be s a ved to the confi gura ti on fi l e.

14.1.1 Basic Settings


The ba s i c s etti ngs confi gura ti on a l l ows you to cha nge va ri ous preferences to s ui t your needs . For mos t us ers ,
the defa ul t s etti ngs a re a dequa te. For more i nforma ti on, s ee:
Ontol ogy La ngua ge 12
Stora ge-rel a ted Opti ons 44

Eva l ua ti on-rel a ted Opti ons 167

156
OntoBroker 6.3 Confi guri ng OntoBroker

14.1.2 Optimization Settings


OntoBroker s upports mul ti pl e opti mi zers (mos t of them jus t rewri te a s et of rul es to a n opti mi zed s et of
rul es ). However, i n s ome ca s es opti mi zers jus t wa s te ti me a nd s pa ce. For exa mpl e, 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 . You ca n fi nd a l l i nforma ti on on opti mi zers
here 170 .

157
OntoBroker 6.3 Confi guri ng OntoBroker

14.1.3 Other Settings


Wi thi n the 'Other s etti ngs '-ta b further OntoBroker s etti ngs ca n be confi gured. Furthermore the OntoBroker
Socket Communi ca ti on a nd the Admi ni s tra ti on Cons ol e HTTP port OntoBroker s houl d us e on s ta rt-up, ca n be
s et. For more i nforma ti on s ee
Server
Securi ty 144
Loggi ng 273

Ful l text Index 274

158
OntoBroker 6.3 Confi guri ng OntoBroker

14.2 Parallelization Settings


OntoBroker ca n us e mul ti pl e CPUs for proces s i ng executi ng s erver comma nds , for l oa di ng ontol ogi es , a nd for
pa ra l l el i zi ng eva l ua ti on of a query. Ea ch of thes e three a rea s ca n be confi gured s epa ra tel y us i ng
confi gura ti on s wi tches .

159
OntoBroker 6.3 Confi guri ng OntoBroker

Command Function

Parallelize.ServerCommands = <on | off> If thi s s wi tch i s on, OntoBroker ca n proces s mul ti pl e


s erver comma nds (e.g. queri es ) from cl i ents a t the
s a me ti me.

Parallelize.ServerCommands.MaxThreads = Thi s s wi tch determi nes the ma xi mum number of


<integer|auto> threa ds us ed for pa ra l l el i zi ng s erver comma nds (onl y
i f Pa ra l l el i ze.ServerComma nds = on). The defa ul t
va l ue i s "a uto", i .e. a utoma ti c confi gura ti on
dependi ng on the number of a va i l a bl e CPUs (cores ).

Parallelize.Loader = <on | off> Thi s s wi tch control s the l oa di ng of mul ti pl e


ontol ogi es . If i t i s turned on, OntoBroker ca n l oa d
mul ti pl e ontol ogy fi l es on a pa ra l l el ba s i s . For
pers i s tent s tora ges (e.g. H2), thi s fea ture i s a l wa ys
turned off a utoma ti ca l l y, a s i t ha s a nega ti ve i mpa ct
on performa nce.

Parallelize.Loader.MaxThreads = <integer| Thi s s wi tch s ets the ma xi mum number of threa ds


auto> us ed for l oa di ng ontol ogy fi l es .

Parallelize.Reasoner = on | off Thi s s wi tch control s the eva l ua ti on of queri es . If i t i s


turned on, the eva l ua ti on of a query ma y be
di s tri buted on mul ti pl e threa ds wherever pos s i bl e.

Parallelize.Reasoner.MaxThreads = Thi s s wi tch determi nes the overa l l number of


<integer|auto> threa ds a va i l a bl e for executi ng query eva l ua ti on
ta s ks .

Parallelize.Reasoner.Connectors. Thi s s wi tch determi nes how ma ny threa ds a re


MaxThreads = <integer|auto> a va i l a bl e for connectors . Every connector ca l l i s
proces s ed i n a s epera te threa d. As connectors
communi ca te wi th externa l res ources , thi s s wi tch
control s the l oa d OntoBroker ca n produce on thes e
res ources .

Parallelize.Joins = on | off Parallelize. Some eva l ua ti on methods s upport two types of


Joins.MaxThreads = <integer> | auto pa ra l l el i za ti on: opera tornet pa ra l l el i za ti on (thi s i s
the OntoConfi g s wi tch "Pa ra l l el i ze.Rea s oner") a nd
joi n-l evel pa ra l l el i za ti on. For the l a tter there i s now
a n expl i ci t s wi tch.

14.3 Performance-Related Configuration Switches


14.3.1 Genetic Optimizer
The geneti c opti mi zer a l l ows the opti mi za ti on of s peci fi c queri es . Thi s opti mi zer i s typi ca l l y us ed before
depl oyi ng ontol ogi es on a producti on s erver. The order of the body l i tera l s ca n be cha nged/permuta ted a nd
thi s mi ght i mprove the i nference s peed dra ma ti ca l l y. If you crea te a l l pos s i bl e permuta ti ons , you ma y fi nd
the perfect res ul t, but thi s woul d ta ke a n extremel y l ong ti me. For 10 rul es wi th 4 body l i tera l s you woul d ha ve
104! pos s i bl e s ol uti ons , for 100 rul es wi th 8 body l i tera l s you woul d ha ve 1008! pos s i bl e s ol uti ons . The i dea
i s , tha t you do not need the bes t res ul t, but a res ul t tha t i s good enough. If you get one cha nge tha t i mproves
the query, i t s houl d be even better when combi ned wi th other pos i ti ve cha nges . For opti mi za ti ons i n s uch
hi gh di mens i ona l s ea rch s pa ces geneti c a l gori thms a re a ppl i ca bl e. Thus the geneti c opti mi zer opti mi zes the
s equence of body l i tera l s i n the rul es us i ng a geneti c a pproa ch. In the i ni ti a l i za ti on proces s a ra ndom
popul a ti on wi l l be crea ted. Thi s popul a ti on i s a defi ned number of i ndi vi dua l s wi th ea ch repres enti ng
exa ctl y one permuta ti on. Thes e i ndi vi dua l s together a re ca l l ed a genera ti on, a s i t i s the fi rs t one thi s one, i s
genera ti on 0. Then the fi tnes s of a l l i ndi vi dua l s wi l l be determi ned. For thi s , the permuta ti ons wi l l be
a ppl i ed a nd the query wi l l be executed. The s ma l l er the eva l ua ti on ti me i s , the better the fi tnes s . The better
the fi tnes s of a n i ndi vi dua l i s the better i s i ts cha nce to contri bute to the fol l owi ng crea ti on of the
i ndi vi dua l s of the next genera ti on. Thei r cha ra cteri s ti cs , the orderi ng of body l i tera l s , wi l l be mi xed a nd a
new popul a ti on wi l l be crea ted. New ra ndom cha nges ma y be ma de. The fi ttes t i ndi vi dua l s urvi ves

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 Comma nds to s end a n opti mi zed query to OntoBroker


<queryID>

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 .

opt_genetic Returns i f a n opti mi za ti on proces s i s currentl y runni ng or not.


isoptimizing
OntoBroker Return Va l ues : The return value is a "string".
Exa mpl e:
opt_genetic file, "test.data", rewrite, timeout, 1000,
module,"<http://www.NewOnto1.org/ontology>", "queryID"

Options Description

file filename fi l e na me for opti mi s a ti ons da ta

rewrite rewri tes the fi l e wi th opti mi s a ti ons da ta i f exi s ts

timeout value opti mi za ti on ti meout (ms )

kill s tops the opti mi za ti on

isoptimizing checks whether the opti mi za ti on i s a l rea dy runni ng

status returns the bes t res ul t of the runni ng opti mi za ti on

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.

then they a re s tored i n a s i ngl e ta bl e "$a s s ertedi s a ":


$assertedisa
-----------------------
Tom Cat
Garfield Cat
Jerry Mouse
SpeedyGonzales Mouse

The ConceptNa mes Ground s wi tch wi l l cha nge thi s to


$assertedisa_Cat
--------
Tom
Garfield

$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.4 Wellfounded Evaluation


OntoBroker i s a bl e to dea l wi th rul es whi ch conta i n rul e cycl es over a nega ted l i tera l . In order to eva l ua te a
query over thes e rul es OntoBroker mus t us e a s peci a l eva l ua ti on s tra tegy ca l l ed "wel l -founded eva l ua ti on". A
wel l -founded eva l ua ti on needs much more ti me a nd s houl d be a voi ded i f pos s i bl e. You ca n a l s o di s s ol ve
cycl es us i ng nega ti ons a nd a ggrega ti ons . If you mus t us e s uch rul es you need to s et the fol l owi ng
confi gura ti on s wi tch:
WellfoundedEvaluation = on
However, you s houl d be a wa re of the performa nce pena l ty for s uch ontol ogi es ("uns tra ti fi ed model s ").

A typi ca l exa mpl e of a n uns tra ti fi ed model i s


person(a).
male(?X) :- person(?X) AND NOT female(?X).
female(?X) :- person(?X) AND NOT male(?X).
Here i t i s not cl ea r whi ch rul e to eva l ua te fi rs t. If you query for "pers on" the res ul t i s "a ", but i f you query for
"ma l e" or "fema l e", the res ul t s et i s empty. The rea s on i s a cycl e over nega ti ons . Thi s rul e gra ph ca n be
di s pl a yed by s etti ng the s wi tch "Vi s ua l i zeStra ti fi ca ti onProbl emDeta i l s =on" a nd s ta rti ng OntoBroker wi th
"Wel l foundedEva l ua ti on=off". If OntoBroker then detects s uch cycl es the cycl es a re di s pl a yed.

14.5 Using OntoBroker with a Persistent Datamodel


OntoBroker currentl y s upports one pers i s tent da ta model : H2 (Embedded SQL engi ne)
The pri ma ry rea s ons for us i ng a pers i s tent da ta model a re:
The a mount of fa cts a nd rul es i s too bi g to s tore everythi ng i n the ma i n memory.
The s erver s houl d s tore da ta pers i s tentl y.
Of cours e OntoBroker wi l l onl y fetch the da ta whi ch i s requi red for rea s oni ng from the pers i s tent s tora ge. Thi s
a l l ows the ha ndl i ng of da ta model s whi ch a re l a rger tha n the a va i l a bl e ma i n memory. When you s ta rt the
OntoBroker s erver then the gi ven fi l es a re s tored di rectl y i n the pers i s tent s tora ge. Hence, you do not need to
gi ve the fi l es a s comma ndl i ne opti ons the next ti me you s ta rt OntoBroker.

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.

14.5.2 Database File Layout


Thi s i s a n excerpt of the H2 webs i te des cri bi ng the da ta ba s e fi l e l a yout. The fol l owi ng fi l es ca n be crea ted by
the da ta ba s e:

File Name Description Number of Files

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

test.lock.db Da ta ba s e l ock fi l e. 1 per da ta ba s e (onl y i f i n


us e)
Automa ti ca l l y (re-)crea ted whi l e the da ta ba s e i s i n us e.
Forma t: <da ta ba s e>.l ock.db

test.trace.db Tra ce fi l e (i f the tra ce opti on i s ena bl ed). 0 or 1 per da ta ba s e


Conta i ns tra ce i nforma ti on.
Forma t: <da ta ba s e>.tra ce.db
Rena med to <da ta ba s e>.tra ce.db.ol d i s too bi g.

test.lobs.db/ Di rectory conta i ni ng one fi l e for ea ch 1 per l a rge object


* BLOB or CLOB va l ue l a rger tha n a certa i n s i ze.
Forma t: <i d>.t<ta bl eId>.l ob.db

test.123. Tempora ry fi l e. 1 per object


temp.db Conta i ns a tempora ry bl ob or a l a rge res ul t s et.
Forma t: <da ta ba s e>.<i d>.temp.db

14.5.3 Configuration Values for Performance Tuning


The mos t i mporta nt pa ra meter i nfl uenci ng the performa nce i s the number of da ta ba s e pa ges , whi ch H2 ca n
keep i n the ma i n memory. By defa ul t thi s va l ue i s s et to 16384 KB. To cha nge thi s va l ue, a dd the CACHE_SIZE
opti on to the H2.URL. The va l ue i s the ma xi ma l ca che s i ze i n KB.
Exa mpl e (s et ca che s i ze to 100000 KB, e.g. a bout 100 MB):
H2.URL = jdbc:h2:file:data/edb;CACHE_SIZE=100000

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

14.5.5 Online Backup


An onl i ne ba ckup ca n be tri ggered us i ng the comma nd "h2ba ckup".

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.

Res tori ng a ba ckup requi res fol l owi ng s teps :


1. Shutdown OntoBroker.
2. Del ete a l l H2 da ta ba s e fi l es , e.g. i f the da ta ba s e i s na med "edb", you ha ve to del ete "edb.*".
3. Copy the ba ckup fi l e to the ol d l oca ti on a nd rena me i t to the ori gi na l na me. E.g i f the da ta ba s e i s na med
"edb", then the da ta ba s e fi l e mus t be na med "edb.da ta .db".
4. Sta rt OntoBroker. On openi ng the da ta ba s e fi l e, the i ndi ces wi l l recons tructed. Thi s procedure ma y ta ke
s ome ti me (typi ca l l y a few mi nutes / GB).

14.6 Configuration Switches for the Server


OntoBroker runs a s a s erver a nd hence ha s to l i s ten to a gi ven port for queri es a nd comma nds to execute. The
s ta nda rd port for OntoBroker i s port <2267> whi ch i s regi s tered a t the IANA orga ni za ti on. Neverthel es s the
us er i s a bl e to cha nge the port i n order to run the s erver on a di fferent port a nywa y. Thi s mi ght become
neces s a ry i f s evera l i ns ta nces of the s erver ha ve to run on the s a me hos t.
CommandPort = 2267

Setting Socket Timeout


Thi s i s a n a dva nced property whi ch s houl d not be cha nged wi thout good rea s ons . The defa ul t s ocket ti meout
for the comma nd port i s s et to 0, mea ni ng "no ti meout". If there a re probl ems wi th unus ua l cl i ent beha vi our,
e.g. connecti ng OntoBroker wi thout s endi ng a comma nd, a s ol uti on ca n be to s et the ti meout to a n
a ppropri a te va l ue (whi ch depends on the number of cl i ents a nd the network l a tency).
SocketTimeout=<milliseconds>

Switch for the Configuration of the Ports


If OntoBroker i s s ta rted wi th one of the comma ndl i ne opti ons "-webs ervi ce", "-col l a bs erver", or "-

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

15 OntoBroker Performance Tuning


The performa nce of OntoBroker ca n be tuned by tryi ng out di fferent confi gura ti on s wi tches (s ee the cha pter
"Confi guri ng OntoBroker"). It i s often us eful to check where the bottl eneck of a s peci fi c query rea l l y i s . You
ca n us e the tra ci ng fea tures to, for exa mpl e, fi nd out i f a s peci fi c bui l t-i n i s the ca us e of the performa nce
probl em (s ee "Tra ci ng the eva l ua ti on proces s "). Bes i des thi s ba s i ca l l y you ha ve the fol l owi ng opti ons :
Us i ng tool s to opti mi ze the s equence of body l i tera l s i n rul es
Ma teri a l i zi ng the rul es on s ta rtup i n order to reduce the query executi on ti mes duri ng runti me

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 Choosing an Evaluation Method


15.1.1 Evaluation Methods
The OntoBroker rea s oni ng engi ne s upports di fferent eva l ua ti on s tra tegi es . Thi s a l l ows the us er to choos e the
eva l ua ti on method whi ch provi des the bes t performa nce cha ra cteri s ti cs for a s peci fi c ontol ogy wi th a s peci fi c
s et of queri es . The eva l ua ti on method ma y a l s o be chos en i ndi vi dua l l y for every query. The fol l owi ng
s ecti ons gi ve a n overvi ew of the di fferent eva l ua ti on methods .

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.

E.g. i f you ha ve a rul e a nd a query


RULE r1: p(?X,?Y) :- q(?X,?Y) AND r(?X,?Y).
QUERY q1: ?- p(?a,"Y").
then fi rs t the rul e "r1" i s eva l ua ted a nd a l l of the i mpl i ca ti ons a re computed. Then the body l i tera l "p(a ,Y)" of
the query "q1" fi l ters a l l tupl es genera ted by "r1" whi ch ha ve a n "a " i n the fi rs t pos i ti on. So, i f rul e "r1"
produces ma ny tupl es , but onl y few tupl es whi ch conta i n a n "a " i n the fi rs t pos i ti on, then a l ot of ti me wi l l be
wa s ted i n "r1". Bes i des thi s performa nce probl em note tha t i t i s not pos s i bl e to eva l ua te a l l rul es bottom-up
(e.g. i f bui l t-i ns a re i nvol ved). In order to s ta rt OntoBroker wi th thi s eva l ua ti on method s et
EvaluationMethod=BottomUp
i n OntoConfi g.prp.

OntoBroker 6 s hi ps wi th the new BottomUp3 eva l ua tor. It onl y works for


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). You s houl d not
mi x RAM.TS wi th Dyna mi cFi l teri ng or Dyna mi cFi l teri ng2 or wi th the BottomUpEva l ua tor BottomUp2.

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

15.1.2 BottomUp Evaluators


Some of the eva l ua ti on methods des cri bed a bove ca n be eva l ua ted wi th a n (a ddi ti ona l ) bottom-up eva l ua tor
onl y:
BottomUp
Di s juncti veMa gi cSet
It's pretty cl ea r tha t the "BottomUp" eva l ua ti on method ca n be eva l ua ted us i ng a bottom-up eva l ua tor. But
why ca n the ma gi c s et methods be eva l ua ted wi th a bottom-up eva l ua tor? The rea s on i s tha t the ma gi c s et
methods jus t rewri te the ori gi na l progra m to a nother progra m whi ch ca n be eva l ua ted fa s ter us i ng a bottom-
up eva l ua tor. So "Ma gi cSet" a nd "Di s juncti veMa gi cSet" a re jus t opti mi zers for the bottom-up eva l ua ti on of
rul es .
OntoBroker 6 s hi ps wi th the new BottomUp3 eva l ua tor. It onl y works for

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.

15.1.2.1 BottomUp Evaluator


Thi s eva l ua tor i s the fa s tes t bottom-up eva l ua tor whi ch i s a va i l a bl e i n OntoBroker. It i s
Very memory effi ci ent
Hi ghl y effi cent on mul ti core/mul ti CPU s ys tems (i t provi des i n-kernel pa ra l l el i za ti on)
BottomUp2 i s a bl e to execute mul ti pl e joi n opera ti ons a t the s a me ti me. BottomUp2 i s the recommended
bottom-up eva l ua tor for the i nference s erver. In order to s ta rt OntoBroker wi th thi s eva l ua tor s et
BottomUpEvaluator=BottomUp2
i n OntoConfi g.prp. In mos t ca s es i t i s s uffi ci ent jus t to s el ect "a uto" (then the number of pa ra l l el rea s oni ng
threa ds i s a utoma ti ca l l y a da pted to the a va i l a bl e number of CPUs ).

15.1.2.2 DBBottomUp Evaluator


Thi s bottom-up eva l ua tor wi l l execute a l l joi n a nd ma tch opera ti ons i ns i de the s tora ge s ys tem. It i s currentl y
the bes t eva l ua tor for ma teri a l i zi ng very l a rge ontol ogi es wi th a da ta ba s e. However, i t i s a l s o a n effi ci ent
eva l ua tor for the RAM s tora ge s ys tems . DBBottomUp works for a l l RAM model s a nd for H2. In order to s ta rt
OntoBroker wi th thi s eva l ua tor s et
BottomUpEvaluator=DBBottomUp
i n OntoConfig.prp.

Note:
You ca n run the eva l ua ti on methods wi th a l l s tora ge s ys tems .

15.1.3 Choosing a Storage System/Evaluation Method/Bottom-Up Evaluator


Fi rs t you s houl d choos e a s tora ge s ys tem. Thi s i s ea s y a s you jus t ha ve to thi nk a bout the requi red
functi ona l i ty (pers i s tence, rena mi ng ca pa bi l i ti es ).

15.1.3.1 Persistent Storage Systems


For the pers i s tent s tora ge s ys tems you s houl d a l wa ys s et
EvaluationMethod=DynamicFiltering2
BottomUpEvaluator=choose
i n OntoConfig.prp.

15.1.3.2 RAM Storage Systems


The recommended s etup for the OntoBroker i nference s erver i s
Storage=RAM.AVL.Packed
EvaluationMethod=choose
BottomUpEvaluator=choose
or
Storage=RAM.TS
EvaluationMethod=choose
BottomUpEvaluator=choose

15.1.4 Config Optimizer


The confi g opti mi zer checks a l l of your s etti ngs (rel a ted to eva l ua ti on method, bottomup el va l ua tor) a nd
choos es the very bes t confi gura ti on for a grea t performa nce. Rea d more a bout the confi g opti mi zer i n „Server
comma nds for confi gura ti on opti mi zer“ 198 .

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 .

15.2.1 Eliminate Redundant Literals


If l i tera l s occur i n both the body a nd hea d of the rul e then they ca n be removed from the hea d. E.g. i f you ha ve
?X:"Person" AND ?X["hasName"->?N] :- ?X:"Person" AND ?X["hasLastName"->?N].
then thi s rewri ter el i mi na tes the "X:Pers on" i n the hea d a nd repl a ces the rul e by
?X["hasName"->?N] :- ?X:"Person" AND ?X["hasLastName"->?N].
It i s recommended tha t you l ea ve thi s opti mi zer a l wa ys a cti va ted.

15.2.2 Propagate Constraints


Thi s rewri ter propa ga tes cons tra i nts l i ke "l es s " or "grea ter" topdown through the rul e gra ph. A s i mpl e
exa mpl e:
QUERY q1: ?- p(?X) AND ?X < 5.
RULE r1: p(?X) :- q(?X).
wi l l be rewri tten to
QUERY q1: ?- p(?X) AND ?X < 5.
RULE r1: p(?X) :- q(?X) AND ?X < 5.
Cons i der the ca s e when you ha ve 1 mi l l i on tupl es i n "q" a nd onl y one fa ct i s l es s tha n 5. Then thi s rewri ter
fi l ters out thes e tupl es i n r1 a nd not l a ter i n q1. However, i f the cons tra i nt does not fi l ter out ma ny res ul ts
then thi s opti mi zer mi ght be counter-producti ve beca us e the "l es s " bui l ti n i s executed twi ce.

15.2.3 Rule Unfolding


Rul e unfol di ng mea ns s ubs ti tuti on of rul e hea ds by rul e bodi es i n other rul es . Lets l ook for a s i mpl e
exa mpl e. 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).
Thi s unfol di ng ha s s ome a dva nta ges :
If q a nd r a nd t a re extens i ona l predi ca tes (there a re no rul es wi th q,r,t i n the hea d) then the cos t-ba s ed
dyna mi c reorderi ng of the rul e l i tera l s provi des better res ul ts . As q,r,t a re extens i ona l predi ca tes , thei r
extens i ons a re di rectl y known (they a re not deri ved) a nd thus s ta ti s ti cs on thes e extens i ons hel p to
reorder the rul e body l i tera l s i n a n opti ma l wa y.
Indi ces mus t not be crea ted dyna mi ca l l y duri ng query eva l ua ti on for i ntens i ona l predi ca tes but a re
crea ted once a nd a re reta i ned for a l l extens i ona l predi ca tes (they a re not deri ved by rul es ) for future
query eva l ua ti ons .
If the s tora ge model i s pers i s tent, i .e. the H2 rel a ti ona l da ta ba s e of the SQL rewri ter crea tes SQL
expres s i ons out of the body l i tera l s . Thi s works for extens i ona l predi ca tes onl y.
For i ntegra ti on s cena ri os wi th externa l da ta ba s es rul es a re a l s o di rectl y rewri tten i nto s ql -s ta tements
whi ch a cces s the externa l da ta ba s es . Beca us e the performa nce i s s trongl y i mproved i f a l ot of externa l
da ta ba s e a cces s es a re combi ned to a few s ql -s ta tements , the us e of the StrongUnfol der i s very often a
very effecti ve opti on.
In contra s t to a wea ker vers i on of unfol di ng, the StrongUnfol der a l s o unfol ds body l i tera l s for whi ch s evera l
rul es exi s t. Thi s i s s hown i n the fol l owi ng exa mpl e
?- q(?X) AND r(?X).
q(?X) :- t(?X).
q(?X) :- s(?X).
Thi s s et of rul es i s unfol ded to the fol l owi ng s et of queri es :
?- s(?X) AND r(?X).
?- t(?X) AND r(?X).

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

15.2.4 Equal Unify Rewriter


Thi s rewri ter opti mi zes the equa l a nd uni fy bui l ti ns . E.g. i f you ha ve
RULE r1: p(?X) :- q(?X) AND _unify(?X,5).
then thi s rul e wi l l be rewri tten to
RULE r1: p(5) :- q(5).

15.2.5 ShrinkDBAccess (Rewriter for External Database Access)


Thi s rewri ter proces s es dba cces s us er l i tera l s . It determi nes the col umns tha t s houl d be s el ected from a
da ta ba s e a nd a dds the l i s t of thes e col umns to dba cces s us er. So onl y the col umns tha t a re needed for the
query wi l l be s el ected from a da ta ba s e a nd the number of da ta ba s e queri es wi l l be reduced.
Exa mpl e
?- _dbaccessuser("projects","F"("id",?VAR1,"project",?VAR2),"conndatasource").
wi l l be rewri tten to
?- _xdbaccessuser("projects","F"("id",?VAR1,"project",?VAR2),"conndatasource",
["ID","PROJECT","CUSTOMER"]).
By executi on of the fi rs t xdba cces s us er a l l three col umns wi l l be s el ected a nd ca ched, s o by the s econd
xdba cces s us er no col umns s houl d be s el ected from a da ta ba s e.

15.2.6 FLToSqlRewriter (Rewriter For External Database Access)


The rewri ter opi mi zes a da ta ba s e a cces s . dba cces s us er l i tera l s a re combi ned wi th s ome bui l ti ns a nd other
dba cces s us er l i tera l s i n one s ql query to ha ve res tri cti ons .
Exa mpl e
?- _dbaccessuser("projects","F"("id",?VAR1,"project",?VAR2),"conndatasource") AND
_unify(?VAR1,"myproject").
wi l l be rewri tten to
?- _sqlexecute("select id, project from projects where project
=’myproject’”,
[VAR1,VAR2],..,"condatasource").

15.2.7 Rewriter for Propagation of Ground Terms in Rule Graph


The cons ta nts i n the rul e gra ph ca n be propa ga ted a nd thus s ometi mes edges ma y be del eted.
Exa mpl e
p("b","X") :- q("X").
t("X","Y") :- p("X","Y").
?- t("a","X").
If there a re onl y fa cts for q thi s query ca nnot del i ver a n a ns wer. Thi s ma y a l rea dy be s een i n the rul e gra ph by
propa ga ti ng the cons ta nt a to the s econd rul e a nd then to the thi rd rul e.

171
OntoBroker 6.3 OntoBroker Performa nce Tuni ng

15.2.8 Schema Optimizer


The s chema opti mi zer a s s umes tha t the whol e s chema i s a va i l a bl e. An exa mpl e: The s chema opti mi zer
a s s umes tha t a n i ns ta nce
JohnDoe:Person[hasName->John]
wi l l a l wa ys ha ve a corres pondi ng s chema i nforma ti on for "Pers on":
Person[hasName=>>xsd#string].
When you crea te ontol ogi es wi th OntoStudi o then i t i s a l wa ys s a fe to turn on the s chema opti mi zer. When
you ma nua l l y edi t ontol ogi es you ha ve to check i f you ha ve the correct s chema i nforma ti on i n your ontol ogy
before a cti va ti ng the s chema opti mi zer.
If you ha ve a rul e:
p(?X,?V) :- ?X:"Person" AND ?X["hasName"->?V].
If the "ha s Na me" onl y occurs for the concept "Pers on" then we jus t cha nge the rul e to
p(?X,?V) :- ?X["hasName"->?V].
Thi s mi ght i mprove performa nce dra ma ti ca l l y, es peci a l l y i f you ha ve ma ny i ns ta nces of "Pers on".
But i t i s pos s i bl e tha t no s chema i nforma ti on exi s ts . In thi s exa mpl e us i ng the s chema opti mi zer wi l l produce
wrong res ul ts i f the
Person[hasName->xsd#string] .
i s mi s s i ng. Us i ng the Schema Opti mi zer mea ns enormous ti me-s a vi ngs i n a n i ntegra ti on s cena ri o.

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.9 Eliminate Bodies


Thi s rewri ter onl y a ffects "dba cces s us er" l i tera l s . It wi l l remove a dba cces s us er l i tera l i f i t i s i denti ca l
(modul o va ri a bl e rena mi ng) to a nother dba cces s us er l i tera l .

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.

The fol l owi ng rul e types a re s upported:


dba cces s rul es a s they a re genera ted by the OS db i mport pl ugi n
Ma ppi ng rul es a s they a re genera ted by the OS ma ppi ng tool
Rul es where ea ch a tt-l i tera l i s a ccompa ni ed by a n a ppropri a te i s a l i tera l i n the hea d a nd body
Cl a s s i fi ca ti on rul es l i ke ?X:D :- ?X:E a nd ... where D i s a s ub concept of E

Res tri cti ons :


The model mus t not conta i n a ny i ns ta nces .
The model mus t be compa ti bl e wi th CNG=on, ANG=on, MNG=on.
Fi l l nul l for the query i s not s upported.
Queri es for i denti fi ers l i ke ?- ?X:C. a re not s upported, onl y queri es for a ttri bute va l ues .
the rul es i nvol ved i n a query mus t be of the type a bove.

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.11 Rewriter for Transitivity Rules


The tra ns i ti vi ty property of rel a ti ons crea tes rul es l i ke:
?X[prop->?Y] :- ?X:domain, ?Z:domain, ?X[prop->?Z], ?Z[prop->?Y].
It i s much more effi ci ent to ha ve ta i l - or hea d-recurs i on i ns tea d of doubl e recurs i on.
The rewri ter crea tes rul es l i ke:
?X[prop->?Y] :- ?X:domain, ?Z:domain, ?X[directprop->?Z], ?Z[prop->?Y].
In a ddi ti on i f ?X i s bound the fol l owi ng rul e i s more effi ci ent:
?X[prop->?Y] :- ?X:domain, ?Z:domain, ?X[prop->?Z], ?Z[directprop->?Y].
otherwi s e (i f ?Y i s bound) the fi rs t rul e i s better.

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 .

15.3 Optimizing the Sequence of Body Literals in Rules


Us es s ophi s ti ca ted heuri s ti cs for opti mi zi ng the s equence of joi n opera ti ons , but s ometi mes the bes t
heuri s ti c i s not a bl e to fi nd out the opti ma l joi n s equence for a s peci fi c query wi th s peci fi c rul es . An exa mpl e
s houl d i l l us tra te thi s . Cons i der the fol l owi ng s equence of body l i tera l s i n the rul e:
QUERY q1: ?- ?P["inTournament"->?WM].
RULE r1: "P"["inTournament"->"WM"].
<-
P:Player. // 1000 tuples
WM:Tournament AND // 25 tuples
WM[match -> M] AND // 30 tuples
M[team -> T] AND // 2 tuples
T[lineup -> P] AND // 11 tuples

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.

15.3.1 Using the Genetic Optimizer


The geneti c opti mi zer a l l ows s peci fi c queri es to be opti mi zed. Thi s opti mi zer i s typi ca l l y us ed before
depl oyi ng ontol ogi es on a producti on s erver. The order of the body l i tera l s ca n be cha nged/permuted a nd
thi s mi ght i mprove the i nference s peed dra ma ti ca l l y. If you crea te a l l pos s i bl e permuta ti ons , you ma y fi nd
the perfect res ul t but thi s woul d ta ke a very very l ong ti me. For 10 rul es wi th 4 body l i tera l s you woul d ha ve
104! pos s i bl e s ol uti ons , for 100 rul es wi th 8 body l i tera l s you woul d ha ve 1008! pos s i bl e s ol uti ons . The i dea
i s tha t you do not need the bes t res ul t but a res ul t tha t i s good enough. If you get one cha nge tha t i mproves
the query, i t s houl d be even better when combi ned wi th other pos i ti ve cha nges . For opti mi za ti ons i n s uch
hi gh di mens i ona l s ea rch s pa ces geneti c a l gori thms a re a ppl i ca bl e. Thus the geneti c opti mi zer opti mi zes the
s equence of body l i tera l s i n the rul es us i ng a geneti c a pproa ch. In the i ni ti a l i za ti on proces s a ra ndom
popul a ti on wi l l be crea ted. Thi s popul a ti on i s a defi ned number of i ndi vi dua l s wi th ea ch repres enti ng
exa ctl y one permuta ti on. Thes e i ndi vi dua l s together a re ca l l ed a genera ti on, a s i t i s the fi rs t one thi s one, i s
genera ti on 0. Then the fi tnes s of a l l i ndi vi dua l s wi l l be determi ned. For thi s , the permuta ti ons wi l l be
a ppl i ed a nd the query wi l l be executed. The s ma l l er the eva l ua ti on ti me i s , the better the fi tnes s . The better
the fi tnes s of a n i ndi vi dua l i s the better i s i ts cha nce to contri bute to the fol l owi ng crea ti on of the
i ndi vi dua l s of the next genera ti on. Thei r cha ra cteri s ti cs , the orderi ng of body l i tera l s , wi l l be mi xed a nd a
new popul a ti on wi l l be crea ted. New ra ndom cha nges ma y be ma de. The fi ttes t i ndi vi dua l s urvi ves
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 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 .

opt_genetic Returns i f a n opti mi za ti on proces s i s currentl y runni ng or not.


isoptimizing OntoBroker Return Va l ues : The return va l ue i s a "s tri ng".
Exa mpl e:
opt_genetic file, "test.data", rewrite, timeout, 1000,
module,"<http://www.NewOnto1.org/ontology>", "queryID"

command.cmd "opt_genetic file, \"test.data\", rewrite, module,


<http://www.ontoprise.de#testonto>, \"queryID\"

Option Description

file filename fi l e na me for opti mi za ti on da ta

rewrite rewri tes the fi l e wi th opti mi za ti on da ta i f i t exi s ts .

timeout value opti mi za ti on ti meout (ms )

kill s tops the opti mi za ti on

isoptimizing checks whether the opti mi za ti on i s a l rea dy runni ng

status returns the bes t res ul t of the runni ng opti mi za ti on

15.3.2 Hillclimbing Optimizer


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.

Usage

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"

command.cmd "opt_hillclimbing file, \"test.data\", rewrite, module, <http://www.


ontoprise.de#testonto>, \"queryID"s\"

175
OntoBroker 6.3 OntoBroker Performa nce Tuni ng

Option Description

file filename fi l e na me for opti mi za ti on da ta

rewrite rewri tes the fi l e wi th opti mi za ti on da ta i f i t exi s ts .

kill s tops the opti mi za ti on

isoptimizing checks whether the opti mi za ti on i s a l rea dy runni ng

status returns the bes t res ul t of the runni ng opti mi za ti on

for all rules r


:= max
fomintime r all body permuations p of r
evaluate query
if evaltime < mintime
mintime = evaltime
minpermutation = p
set body permutation of r to minpermutation
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

Additonal information about the hillclimbing algorithm:


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, ea ch ti me i mprovi ng i t a l i ttl e. When the a l gori thm ca nnot s ee a ny i mprovement a nymore, 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.

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

?- ?X:Person AND ?X[hasName->?Y] AND ?X[worksAt->?Z].


?- ?X[hasName->?Y] AND ?X:Person AND ?X[worksAt->?Z].
?- ?X[hasName->?Y] AND ?X[worksAt->?Z] AND ?X:Person.
...

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

15.4 Tracing the Evaluation Process


OntoBroker ha s s ome us eful fea tures whi ch hel p to a na l yze performa nce a nd to tra ce the eva l ua ti on proces s .
###########################################################
# Trace (only has Effect when using 'trace' Query Option)
# NOTE: For Statistics about Query Execution
# use the 'profile' Query Option.
###########################################################
#Trace.Evaluation = off
#Trace.Evaluation = simple
#Trace.Evaluation = rules
#Trace.Evaluation = full
#Trace.Rewriter = on
#Trace.Rules = off
#Trace.Queries = on
#Trace.Datamodel.Changes = on
#Trace.Datamodel.Requests = on
#Trace.Materialization = on

Thi s i s a n expert fea ture whi ch gi ves extens i ve l og i nforma ti on:


Di s pl a y of s el ected rul es
Beha vi or of i ndi vi dua l rewri ters
Fl ow of tupl es through the opera tornet
Shows the l ogged reques ts on da ta model (vi a Ja va -API)

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

When thes e opti ons a re s et then OntoBroker wi l l s how


Informa ti on a bout the da ta ba s e s chema
Informa ti on a bout SQL da ta ba s e reques ts (SQL query, number of res ul ts )
Exa mpl e
@{q1, options[trace]} ?- ?X::Company.
The rul es l i s ted i n the output a re a l l rul es whi ch a re rel eva nt for the eva l ua ti on (thi s i s i n mos t ca s es a
s ubs et of the tota l rul es ). Duri ng the eva l ua ti on s ta ti s ti cs a re ga thered whi ch hel p gi ve a n i mpres s i on of the
eva l ua ti on cha ra cteri s ti cs of rul es . Often the ca us e for the poor eva l ua ti on ti me of a rul e l i es i n s ome bui l t-
i n or connector (es peci a l l y da ta ba s e connectors ca n ta ke up a l ot of ti me).
If you a re i nteres ted i n how OntoBroker a ctua l l y eva l ua tes the rul es , you ca n turn on ful l tra ci ng "Tra ce.
Eva l ua ti on=ful l ". Then you wi l l s ee the fl ow of tupl es through the opera tornet. Note tha t the output i s very
ha rd to rea d a nd i nterpret. The pri ma ry us e ca s e of thi s fea ture i s tha t you ca n s end the OntoBroker output for
a s peci fi c query to the ontopri s e s upport tea m, to, for exa mpl e, hel p reproduce a bug or expl a i n a n
unexpected res ul t.

15.5 Use Materialization of Rules and/or Axioms


A good wa y to opti mi ze the query performa nce i s to ma teri a l i ze the rul es a nd/or the s ta nda rd a xi oms .
Ma teri a l i za ti on s i mpl y mea ns tha t rul es a re executed a nd tha t the res ul ts a re s tored a s fa cts . For s ubs equent
queri es the ma teri a l i zed rul e wi l l no l onger be cons i dered.

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.

Find rules & retrieve rule text


Us e the bui l t-i ns _rul eByID/3 a nd _queryByID/3 to retri eve the rul e text for a gi ven rul e ID a nd modul e. If you
onl y need the rul e IDs of a gi ven modul e, you ca n us e the bui l t-i ns _i s Rul e/2 a nd _i s Query/2.
Exa mpl e
"G ive m e the rule text of all rules in all m odules"
?- $module(?M) AND _ruleByID(?M,?ID,?TXT).

Search for rules containing a ObjectLogic term


The bui l t-i ns _rul eConta i ns Term/4, _queryConta i ns Term/3 ca n be us ed to retri eve a l l rul es a nd queri es
res pecti vel y conta i ni ng a n F-l ogi c term i n rul e hea d or body.
Exa mpl e
"G ive m e the rule IDs of all rules in m odule 'm 1' containing the concept 'Person' in the rule body"
?- _ruleContainsTerm("m1","Person","_false",?ID).

Full-text search support for rules


The rul e text a nd the rul e meta da ta a re ful l -text i ndexed. The bui l t-i n queryIndex/10 ca n be us ed to s ea rch
text i n rul es . Add "+type:u" to the l ucene query text to res tri ct the query to rul es or "+type:q" to res tri ct to
queri es . The Sea rchHel per cl a s s of the OntoBroker API a l s o s upports thi s functi ona l i ty.

Commands for adding and removing rules


Comma nds for ObjectLogi c:
insert rule { ruleText ...}
delete rule { ruleText ... }
delete rule ruleID1,ruleID2,.. .

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

Thi s wi l l return the fol l owi ng res ul ts :

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$

Thi s woul d be expres s ed i n the ObjectLogi c rul e


@{ruleColleague_EXPLANATION}
_explain(?QK,?I,?S) :-
(?I:<obl:default:Instantiation>[<obl:default:ruleid> -> ruleColleague],
?I[<obl:default:variables> -> <obl:default:i>(<obl:default:A>,?var_A)],
?I[<obl:default:variables> -> <obl:default:i>(<obl:default:D>,?var_D)],
?I[<obl:default:variables> -> <obl:default:i>(<obl:default:F>,?var_F)],
_applyStringTemplate("$A$ and $D$ are colleagues because they are both employees
of the company $F$",[], [<obl:default:A>(?var_A),<obl:default:D>(?var_D),<obl:
default:F>(?var_F)],?S))@$prooftreefacts(?QK).

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

?S: i s the textua l repres enta ti on of the expl a na ti on


Thi s wi l l a ctua l l y bri ng the fol l owi ng res ul t for thi s ontol ogy:

Generating Explanation Rules


OntoBroker provi des a bui l t-i n for a utoma ti ca l l y genera ti ng expl a na ti on templ a tes . As s ume you wa nt to
genera te a n expl a na ti on rul e for the fol l owi ng rul e:
@{R1}
?-
aPerson1[hatKind->aPerson3]
:-
aPerson1:Person AND
aPerson2:"Person AND
aPerson3:"Person AND
aPerson1[hasChildWith(aPerson2)->aPerson3].
Fi rs t of a l l you ca n us e the bui l t-i n _genera teExpl a na ti onTempl a te/4 to genera te the defa ul t expl a na ti on
templ a te:
?- _generateExplanationTemplate("m1","R1","",?OUT).

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

$aPerson2$ is a Person AND


$aPerson3$ is a Person AND
$aPerson1$ ns_(#,hasChildWith($aPerson2$)) $aPerson3$""",?OUT).

Generated explanation rule


explain_(QK,I,S) <-
I:Instantiation[ruleid->R1]@prooftreefacts_(QK)
AND I[variables->i(aPerson1,var_aPerson1)]@prooftreefacts_(QK)
AND I[variables->i(aPerson3,var_aPerson3)]@prooftreefacts_(QK)
AND I[variables->i(aPerson2,var_aPerson2)]@prooftreefacts_(QK)
AND _applyStringTemplate(\'$aPerson1$ hatKind $aPerson3$
BECAUSE
$aPerson1$ is a Person AND
$aPerson2$ is a Person AND
$aPerson3$ is a Person AND
$aPerson1$ ns_(#,hasChildWith($aPerson2$))
$aPerson3$\',[],[aPerson1(var_aPerson1),aPerson3(var_aPerson3),aPerson2
(var_aPerson
2)],S)@prooftreefacts_(QK).'

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

18 File Encodings and Unicode


OntoBroker s upports the l oa di ng of fi l es of di fferent encodi ngs , e.g. UTF-8 or l a ngua ge (a nd pl a tform) s peci fi c
encodi ngs l i ke <CP1251> for Cyri l l i c Wi ndows s ys tems . The fol l owi ng rul es a ppl y:
OntoBroker i nterprets a l l ObjectLogi c fi l es us i ng the s ys tem s ta nda rd encodi ng. XML-ba s ed forma ts (RDF
(S), OWL) a re i nterpreted a ccordi ng to the fi l e-encodi ng s peci fi ed i n the XML fi l e i ts el f.
Upon l oa di ng, OntoBroker ca n be forced to us e a s peci a l encodi ng for a fi l e by us i ng the -fenc pa ra meter,
e.g.
start-ontobroker -fenc cp1251 russianCars.obl
When s eri a l i zi ng F-l ogi c fi l es , the s ta nda rd s ys tem encodi ng or (when s peci fi ed) the s el ected encodi ng
i s chos en. XML-ba s ed forma ts wi l l a l wa ys be s eri a l i zed i n UTF-8.
The OntoBroker Ja va API provi des s evera l s a ve/export methods for s tori ng ontol ogi es . Thes e methods ha ve
pa ra meters whi ch a l l ow the output encodi ng to be s peci fi ed.

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)

Determi ni ng the OntoBroker home di rectory:


1. If the envi ronment va ri a bl e ONTOBROKER_HOME i s s et, i t i s us ed.
2. If the Sys tem property ontobroker.home i s s et, i t i s us ed.
3. If the Sys tem property ja va .cl a s s .pa th conta i ns the com.ontopri s e.ontobroker.l a uncher ja r fi l e,
OntoBroker home i s recons tructed from i ts pa th.
4. As a l a s t fa l l -ba ck the current di rectory i s tri ed.
The Ontobroker home di rectory i s a l s o a dded a s "ontobroker.home" to the s ys tem properti es .

Determi ni ng the l og4j confi gura ti on:


1. If the OntoConfi g.prp conta i ns the pa ra meter "l og4j.confi gura ti on", i ts va l ue i s us ed.
2. If there i s a "l og4j.properti es " i n the worki ng di rectory, i t i s us ed.
3. If there i s a "l og4j.properti es " i n the ONTOBROKER_HOME di rectory, i t i s us ed.

Determi ni ng the extens i ons di rectory:


1. If the OntoConfi g.prp conta i ns the pa ra meter "Extens i ons .Di rectory", i ts va l ue i s us ed.
2. If there i s a "extens i ons " s ubdi rectory i n the worki ng di rectory, i t i s us ed.
3. If there i s a "extens i ons " s ubdi rectory i n the ONTOBROKER_HOME di rectory, i t i s us ed.

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

os gi .confi gura ti on.a rea =$ONTOBROKER_HOME/conf


fel i x.fi l ei ns ta l l .pol l =3000
org.ecl i ps e.equi nox.http.jetty.cus tomi zer.cl a s s =com.ontopri s e.ontobroker.jetty.cus tomi zer.
OntoBrokerJettyCus tomi zer

Hint for OSGi-related problems:


If the col l a bora ti on s erver coul d not be s ta rted (the mes s a ge INFO [COLLAB_SRV] Collaboration
Server initialized i s not di s pl a yed) i t often hel ps to del ete the conf/org.ecl i ps e.os gi fol der of your
OntoBroker i ns ta l l a ti on. Thi s fol der conta i ns ca ched confi gura ti on da ta .

19.1.1 New Configuration Parameters


Al l s wi tches ca n be s et i n the confi gura ti on fi l e OntoConfig.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).

185
OntoBroker 6.3 OntoBroker Server

New Configuration Description Values Replacement


Parameter

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.

CollaborationServer If s et to on, the Default: off Thi s i s a n a l terna ti ve to


col l a bora ti on s erver i s the comma nd l i ne opti on
s ta rted. CollaborationServer
-collabserver.
= on

RemoteAPI If s et to on, the remote Default: off Thi s i s a n a l terna ti ve to


API i s a va i l a bl e. Remote the comma nd l i ne opti on
API a nd col l a bora ti on RemoteAPI = on -remoteAPI.
s erver ca nnot be s et to
s ta rted a t the s a me ti me.

WebServices If s et to true, the Web Default: off Thi s i s a n a l terna ti ve to


s ervi ces a re depl oyed the comma nd l i ne opti on
a nd a va i l a bl e on the WebServices = on -webservice.
HTTP port under the
pa th /s ervi ces .

WebConsole If s et to true, the web Default: off Thi s i s a n a l terna ti ve to


cons ol e i s a va i l a bl e on the comma nd l i ne opti on
the HTTP port under the WebConsole = on -webconsole.
pa th /cons ol e/cons ol e.
html .

log4j.configuration The pa th to the l og4j. Default: log4j.


properti es . properties
log4j.configuration
= c:/mylog4j.
properties

Configuration. The pa th to the Default: conf Thi s repl a ces the ol d


Directory confi gura ti on di rectory. confi gura ti on pa ra meter
Configuration.
dir.conf.
Directory = conf

AJP Ena bl es the AJP protocol AJP = on


(us ed for l oa d ba l a nci ng).
Note tha t the AJP protocol
ca nnot be us ed i f HTTPS
i s ena bl ed.

AJP.Port Port us ed for the AJP AJP.Port = 12345


protocol (defa ul ts to
8009). Thi s pa ra meter i s
onl y a cti ve i f the AJP
protocol i s ena bl ed.

WorkerName Worker na me us ed for WorkerName = ob3


i denti fyi ng a n OntoBroker
i ns ta nce i n a l oa d
ba l a nci ng cl us ter.

186
OntoBroker 6.3 OntoBroker Server

19.2 Use the OntoBroker Server from commandline


OntoBroker ca n be s ta rted from comma ndl i ne by ei ther us i ng the s cri pt s ta rt-ontobroker.cmd (on Wi ndows ) or
s ta rt-ontobroker.s h (on Li nux). On Wi ndows pl a tforms you ma y a l s o us e OntoBroker32/64.exe. Thi s executa bl e
does the s a me a s the s ta rt-ontobroker.cmd: i t a utoma ti ca l l y rea ds a l l JAR fi l es wi thi n the l i b di rectory a nd
executes the i nference s erver. Us i ng OntoBroker.exe ma kes i t ea s y to i ntegra te OntoBroker i n your own
s cri pts .
The fol l owi ng comma nd i s us ed to l a unch the s erver:
start-ontobroker.cmd [options] [filenames]
start-ontobroker.sh [options] [filenames]

-configFile <configFile> The configuration file to be used (default: OntoConfig.prp).

-project <projectFile> Us e project fi l e for a dva nced l oa d confi gura ti on.

-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

-webconsole Ena bl es OntoBroker web cons ol e. Al terna ti vel y us e the pa ra meter


WebCons ol e = 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.

-m Ma teri a l i ze the fol l owi ng fi l e or di rectory

-m:update Ma teri a l i ze the fol l owi ng fi l e or di rectory (upda ta bl e)

-commitDuringImport Executed mul ti pl e commi ts whi l e l oa di ng a fi l e

-silent Turns off l oggi ng

-rdf,-rdfs,-obl,-owl,-nt, Expl i ci tl y s peci fi es the da ta forma t for rea di ng


-nt3 <directory or
filename>

-help,-h Pri nts us a ge text a nd exi ts

-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

A query i s s ent to the s erver us i ng the comma nd l i ne cl i ent:


query.cmd [-h <hostname>] [-p <portno>] [-l <user>:<pwd>] <query>
query.sh [-h <hostname>] [-p <portno>] [-l <user>:<pwd>] <query>

A comma nd i s s ent to the s erver us i ng the comma nd l i ne cl i ent:


command.cmd [-h <hostname>] [-p <portno>] [-l <user>:<pwd>] <command>
command.sh [-h <hostname>] [-p <portno>] [-l <user>:<pwd>] <command>
The opti ona l a rguments <hos tna me> a nd <portno> a l l ow a cces s i ng the s erver on a di fferent hos t on the
s peci fi ed port. If no <hos tna me> i s gi ven the l oca l hos t i s us ed. If no port number i s gi ven the s ta nda rd port
2267 i s us ed. When l ogi n i s requi red credenti a l s ca n be gi ven wi th the opti ona l a rguments <us er> a nd <pwd>.

19.3 Server Commands


You ca n us e the "comma nd.s h" or "comma nd.cmd" s cri pt to execute OntoBroker s erver comma nds .

Command Client (command.cmd/command.sh)


The comma nd cl i ent provi des a n a ddi ti ona l opti on for s peci fyi ng a comma nd fi l e:
command.cmd -cf myCommandFile.txt
The fi l e i s l oa ded a nd the comma nd i s executed.

Writing Your Own Commands


Externa l comma nds ca n now be a dded a s extens i on pl ugi ns to OntoBroker. Ja va cl a s s es i mpl ementi ng the
Si mpl eAPIComma nd i nterfa ce a re pa cka ged i n a pl ugi n exporti ng a Comma ndProvi der s ervi ce a nd ca n be us ed
wi th OntoBroker by depl oyi ng the ja r fi l e to the extens i ons di rectory.
Comma nd cl a s s
An externa l comma nd i s i mpl emented a s a Ja va cl a s s i mpl ementi ng the i nterfa ce com.ontoprise.api.
command.SimpleAPICommand.
public interface SimpleAPICommand {
String getCommandName();
Object execute(OntologyManager ontologyManager, Term[] args) throws
KAON2Exception, InterruptedException;
}

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

-runscript command line option


OntoBroker now s upports a -runs cri pt comma nd l i ne opti on for executi ng a comma nd or comma nd l i s t from a
fi l e duri ng l a unchi ng.

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.

// try block to ensure execution of final shutdown command


try {
// first insert some facts
insert {
Person[name {0:1} *=> _string, age {0:1} *=> _int].
p1:Person[name->"Susan",age->11].
p2:Person[name->"Mike",age->12].
}
// save Ontology <http://yourcompany.com#m1> to the file m1.obl
save m1 to "m1.obl".
}
// shutdown OntoBroker
shutdown

189
OntoBroker 6.3 OntoBroker Server

19.3.1 Basic Commands

Command Function / Explanation


analyzeSt Thi s comma nd ca n be us ed to upda te the s ta ti s ti cs of the OntoBroker s tora ge. Recommended
orage to execute a fter l a rge upda tes when H2 s tora ge i s us ed.
Exa mpl e:
_ontobrokerManager.executeCommand("analyzeStorage")
Res ul t: "Stora ge a na l yzed i n 42 ms .W

busy Returns the s erver s ta tus .


s ynta x: bus y
OntoBroker Return Va l ues : true, fa l s e
cl i ent-s i de output: "[INFO]: Server bus y s ta te: [true|fa l s e]"

clear Al l s tored a ns wers i n the ca che a re removed


s ynta x: cl ea r
OntoBroker Return Va l ues : ca che cl ea red

commands Returns a l i s t of a l l a va i l a bl e comma nds i n the s erver


s ynta x: comma nds
OntoBroker Return Va l ues : A l i s t wi th a l l s erver comma nds

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

Here i s a n exa mpl e of how to us e del ete i ns tea d of del .


Ol d s ynta x i n OntoBroker 5.3
del otto[age->18]. // syntax from OB 5.3, invalid in OntoBroker 6.3
In OntoBroker 6.1 the corres pondi ng comma nd i s
delete otto[name->"Otto"].
The del ete comma nd i s us ed to remove fa cts a nd rul es from a n ontol ogy. Its s ynta x i s very
s i mi l a r to the i ns ert s ynta x.
Exa mpl e wi th s i ngl e fa ct:
:- module <http://yourcompany.com/ontology1>.
delete Person[name *=> _string].
Exa mpl e wi th mul ti pl e fa cts a nd rul es :
:- module <http://yourcompany.com/ontology1>.
delete {
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 .
}
Exa mpl e wi th where cl a us e:
delete {p(?X,?Y),q(?X),q(?Y).} where {@{options[inferOff]} ?- p(?Y,?X).}

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

Thi s s wi tch ca n be s et i n OntoConfi g.prp vi a :


<SerializerEscapeNewLines> = <on|off>

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#".

// Spec for Input


in#Parameters[in#message {1:1} *=> _string].

// Spec for Output

191
OntoBroker 6.3 OntoBroker Server

out#Results[out#echo {0:1} *=> _string].

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

Res tori ng a ba ckup requi res the fol l owi ng s teps :


1. Shutdown OntoBroker
2. Del ete a l l H2 da ta ba s e fi l es , e.g. i f the da ta ba s e i s na med "edb", you ha ve to del ete "edb.
*".
3. Copy the ba ckup fi l e to the ol d l oca ti on a nd rena me i t to the ori gi na l na me. E.g i f the
da ta ba s e i s na med "edb", then the da ta ba s e fi l e mus t be na med "edb.da ta .db".
4. Sta rt OntoBroker. On openi ng the da ta ba s e fi l e, the i ndi ces wi l l be recons tructed. Thi s
procedure ma y ta ke s ome ti me (typi ca l l y a few mi nutes /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.

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

isalive Checks whether the s erver i s up a nd runni ng


s ynta x: i s a l i ve
OntoBroker Return Va l ues : Inference Server on port 2267 i s up a nd runni ng ...

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

reload Ca us es the s erver to rel oa d a l l fi l es from the s ta rt-up


s ynta x: rel oa d

193
OntoBroker 6.3 OntoBroker Server

OntoBroker Return Va l ues : -

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

shutdown Shutdown wi thout a rgument ca us es OntoBroker to proces s a l l outs ta ndi ng queri es a nd


comma nds , but no new queri es a nd comma nds a re a ccepted a nymore. The va ri a nt "s hutdown
NOW" ca us es OntoBroker to drop a l l wa i ti ng queri es a nd comma nds a nd to s top a l l runni ng
queri es a nd comma nds i mmedi a tel y i n a control l ed wa y. Al s o s ee the ki l l comma nd.
s ynta x: s hutdown [NOW]
OntoBroker Return Va l ues : [INFO]: i nference s erver s hutti ng down ...

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

showUserR The comma nd s i mpl y runs the query


oles ?- currentUser[hasRole -> ?R].

19.3.2 Prepared Queries


For compl ex queri es the prepa ra ti on of the rul es a nd the opti mi za ti on of the eva l ua ti on s tra tegy ma y ta ke a
l ot of ti me (up to 60% of the whol e a ns weri ng proces s wa s reported i n s ome ca s es ). To i mprove the
performa nce of query prepa ra ti on, the query a ns weri ng ha s been di vi ded i nto two s teps :
The prepa ra ti on pha s e a nd
The executi on pha s e
Thi s a l l ows the re-us a ge of prepa red progra ms when queryi ng the s a me or a s i mi l a r query. Si mi l a r mea ns i n
terms of gi ven va l ue res tri cti ons tha t ca n be cha nged before the executi on ta kes pl a ce.

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

Command Function Syntax OntoBroker Return


Values

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 .

preparedquerylist Returns a l i s t of na mes of preparedquerylist [<l i s t-of-prepa red-query-


a l l prepa red queri es i n na mes >]
the s erver. If no queri es
exi s t a n empty l i s t i s
returned.

Removepreparedquery Removes a prepa red removepreparedquery Prepa redQuery


query wi th the gi ven <queryname> <queryna me> removed
na me. If no query exi s ts from s erver
no error i s reported.

Aim Syntax Semantics


Prepa ri ng a query preparequery [temporary Thi s comma nd s ends the gi ven
facts] <objectlogic-query> query to the s erver. The na me wi l l
[fillnull] be us ed to i denti fy the query for
where further us a ge i n comma nds . When
<objectlogic-query> := i t i s expected to execute the query
QUERY <queryname>: wi th tempora ry fa cts a s a mpl e s et
<objectlogic> of thes e tempora ry fa cts s houl d
a l s o be s uppl i ed for the
a nd
prepa ra ti on proces s . The
<objectlogic> := any valid prepa ra ti on of the query depends
objectlogic query that may on the cha ra cteri s ti cs of the fa cts
contain constants _ti which i n the EDB. If the cha ra cteri s ti cs
supply placeholders cha nge between the prepa ra ti on
a nd the executi on of a query, the
s erver del i vers a n error a nd i t i s
neces s a ry to recompi l e the query.
As tempora ry fa cts ma y cha nge
thes e cha ra cteri s ti cs , we
recommend tha t you s end a
s a mpl e s et of thes e fa cts .

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

va l ues for a gi ven executi on.


For exa mpl e, i f there a re two
s ubs ti tuti on pl a cehol ders , i .e. _t1
a nd _t2, the s ubs ti tuti on fa cts
mus t l ook l i ke thi s :
substitute(<value for _t1>,
<value for _t2>)@pq.
Removi ng a prepa red query removepreparedquery Removes a prepa red query wi th
<queryname> the gi ven na me. If no query exi s ts
no error i s reported.

Getti ng a l i s t of a l l prepa red preparedquerylist Returns a l i s t of na mes of a l l


queri es prepa red queri es i n the s erver. If
no queri es exi s t a n empty l i s t i s
returned.
Sa mpl e
Prepa re a query by executi ng the
fol l owi ng comma nd:
preparequery QUERY myQuery:
- p(?X) AND ?X < "_t1".
Show l i s t of prepa red queri es by
executi ng the comma nd:
preparedquerylist
Run the prepa red query us i ng a ny
i nterfa ce a va i l a bl e to run a norma l
query:
p(1).
p(2).
p(3).
substitute(2.5)@pq.
?- PREPARED_QUERY
("myQuery",?X).
Remove the prepa red query by
executi ng the comma nd:
removepreparedquery myQuery

19.3.3 Optimizer Commands


Options Description

file filename fi l e na me for opti mi za ti on da ta

rewrite rewri tes the fi l e wi th opti mi za ti on da ta , i f i t exi s ts

timeout value opti mi za ti on ti meout (ms ).

kill s tops the opti mi za ti on.

isoptimizing checks whether the opti mi za ti on i s a l rea dy runni ng

status returns the bes t res ul t of the runni ng opti mi za ti on

19.3.3.1 Genetic Optimizer


opt_genetic <queryID>

Comma nds to s end a n opti mi zed query to OntoBroker

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 .

opt_genetic Returns i f a n opti mi za ti on proces s i s currentl y runni ng or not.


isoptimizing OntoBroker Return Va l ues : The return va l ue i s a "s tri ng".
Exa mpl e:
opt_genetic file, "test.data", rewrite, timeout, 1000,
module,"<http://www.NewOnto1.org/ontology>", "queryID"

Options Description

file filename fi l e na me for opti mi za ti on da ta

rewrite rewri tes the fi l e wi th opti mi za ti on da ta , i f i t exi s ts

timeout value opti mi za ti on ti meout (ms ).

kill s tops the opti mi za ti on.

isoptimizing checks whether the opti mi za ti on i s a l rea dy runni ng

status returns the bes t res ul t of the runni ng opti mi za ti on

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

file filename fi l e na me for opti mi za ti on da ta

rewrite rewri tes the fi l e wi th opti mi za ti on da ta , i f i t exi s ts

kill s tops the opti mi za ti on.

isoptimizing checks whether the opti mi za ti on i s a l rea dy runni ng

status returns the bes t res ul t of the runni ng opti mi za ti on

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

19.3.4 Server Commands for Configuration Optimizer


Us a ge:
check_opt_config [option(FULL|QUICK|DBACCESS)], query, module
Exa mpl e:
check_opt_config FULL, "?-p(?X)", "<http://www.NewOnto1.org/ontology>"
Res ul t:
The res ul t of the comma nd i s a ti me s ta ti s ti c for di fferent confi gura ti ons (or for the fa s tes t confi gura ti on by
qui ck opti mi za ti on). The fa s tes t confi gura ti on won't be s a ved a utoma ti ca l l y s o the us er s houl d s et i t
ma nua l l y.

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

19.3.5 Load Save


Save command (saves an ontology to a file)
Synta x save <module> to <file>.

Exa mpl e save "http://acme.com#"#ontology1 to '/home/me/ontology.obl'.

OntoBroker repl y Module "http://acme.com#"#ontology1 saved to file:/home/me/ontology.


obl

Si de-effect Ontol ogy i s s a ved to gi ven fi l ena me.

Load command (loads an ontology from a given URL or file)


Synta x load <URL>.
load "file".

Exa mpl e for URL load


<file/sample/sample.obl>.

OntoBroker repl y 1 ontologies loaded.

Exa mpl e for l oca l load


fi l e "E:/me/documents/ontology.obl"

OntoBroker repl y 1 ontologies loaded.

About the load command:


Keep i n mi nd tha t the <l oa d> comma nd onl y s ends a n order to the s erver to l oa d a n ontol ogy. The s erver
i ts el f mus t ha ve a cces s to the ontol ogy!
You ha ve two di fferent opti ons :
Send a n a cces s i bl e URL to the s erver a nd the s ever wi l l be a bl e to l oa d the ontol ogy.
Send a l i nk to a n a cces s i bl e fi l e.
The s upported protocol s a re http, https (bei WebDAV), fi l e a nd ftp.

19.3.6 Drop Module


Del etes one or more ontol ogi es .

Drop Module

Synta x dropModule <module1> [,<module2>,...].

Exa mpl e dropModule "http://acme.com#"#ontology1,"http://acme.com#"#ontology2.

OntoBroker repl y Modules "http://acme.com#"#ontology1, "http://acme.com#"#ontology2


have been dropped.

19.3.7 Delete Rule


Removes one or more rul es from a n ontol ogy.

Delete Rule

Synta x deleteRule <ruleID>@<module>.

Exa mpl e deleteRule "http://acme.com#"#rule2@"http://acme.com#"#ontology1.

OntoBroker repl y Rule "http://acme.com#"#rule2@"http://acme.com#"#ontology1 deleted.

199
OntoBroker 6.3 OntoBroker Server

19.4 Sessions in OntoBroker


As of vers i on 6.1, OntoBroker now s upports s es s i ons wi th pri va te s es s i on fa cts . Thi s mea ns tha t the s es s i on
us er ca n a dd fa cts to a ny a l rea dy exi s ti ng modul es , but nobody but hi m/her ca n s ee thes e a ddi ti ona l fa cts .
On queryi ng, OntoBroker does not di fferenti a te between s ta ti c fa cts a nd s es s i on fa cts , s o eva l ua ti on of rul es
works on both s ta ti c a nd s es s i on fa cts . Bes i des s tori ng fa cts , a s es s i on ca n a l s o s tore a ddi ti ona l s es s i on
s etti ngs s uch a s the defa ul t modul e, defa ul t na mes pa ce a nd a ddi ti ona l na mes pa ce prefi x defi ni ti ons .
An OntoBroker s es s i on ca n be s ta rted us i ng va ri ous i nterfa ces
Socket client: A new s es s i on s ta rts a utoma ti ca l l y on openi ng a n OntoBrokerConnecti on, by ca l l i ng the
method.

OntoBrokerConnectionManager.getConnection(…)

OntoBroker Web service: Ca l l s the opera ti on startSession(…)


OntoBroker API: If your code runs i n the s a me VM a s OntoBroker, ca l l the method startSession(…) of the
Ses s i onMa na ger from the OntoBroker API

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.

Using Sessions with OntoBroker API


Ses s i ons ha ve two ma i n i nterfa ces i n the OntoBroker API. The Ses s i onMa na ger i nterfa ce i s us ed to crea te
new s es s i ons or to retri eve exi s ti ng s es s i ons by the s es s i on i d.

// create new session


SessionFacade sf1 =
sm.createSession(user,password,params);

// retrieve existing session by id


SessionFacade sf2 = sm.getSession(sessionId);

The Ses s i onFa ca de i nterfa ce provi des a l l s es s i on functi ona l i ti es :


Addi ng a nd removi ng fa cts to/from the s es s i on
Runni ng queri es wi thi n the s es s i on
Executi ng comma nds wi thi n the s es s i on
Cl os i ng s es s i ons
Getti ng/s etti ng s es s i on a ttri butes l i ke defa ul t modul e, defa ul t na mes pa ce a nd na mes pa ce prefi xes
Informa ti on a bout the s es s i on l i ke s es s i on i d, s es s i on us er, hos t, l a s t a cces s ti mes ta mp, crea ti on
ti mes ta mp
Checki ng s es s i on va l i di ty

See Ja va Doc for org.semanticweb.kaon2.api.SessionFacade, for deta i l s a bout i ts methods . The


Ses s i onFa ca de i nterfa ce i s not the s es s i on i ts el f, i .e. there ca n be mul ti pl e Ses s i onFa ca de objects
referenci ng the s a me s es s i on.

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.

New Query Options


When runni ng queri es wi thi n a s es s i on, there a re three "da ta s ources " for fa cts :
Sta ti c fa cts (i .e. the s tora ge EDB defi ned by the s tora ge pa ra meter i n the OntoConfi g.prp)
Ses s i on fa cts (i .e. the s es s i on EDB)
Tempora ry fa cts (fa cts a nd rul es provi ded together wi th the query)
In s ome s i tua ti ons queri es s houl d excl ude one of thes e da ta s ources . For thi s purpos e there a re now two
new query opti ons :
ignoreSession - i gnore a l l s es s i on fa cts
Exa mpl e
@{options[ignoreSession]} ?- ?P:Person.

ignoreStorage - i gnore a l l fa cts from the s tora ge EDB


Exa mpl e
@{opti ons [i gnoreStora ge]} ?- ?P:Pers on.

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

The va ri a bl es a re bound a s fol l ows :


?Id - s es s i on i d
?Type - "s es s i on" or "col l a b"
?User - us er na me (ma y be nul l i f us er i s unknown)
?Host - hos t the cl i ent i s connected from (ma y be nul l i f hos t i s unknown)

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

"hos t" hos t

"s ta rtTi mes ta mp" s ta rt ti mes ta mp of s es s i on

"defa ul tModul e" defa ul t modul e

"na mes pa ces " ma p wi th na mes pa ce prefi xes

"fa cts " number of fa cts s tored i n thi s s es s i on

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

The va ri a bl es a re bound a s fol l ows :


?User - us er na me of the current s es s i on (ma y be nul l i f the us er i s unknown)
?Host - hos t of the cl i ent of the current s es s i on (ma y be nul l i f the hos t i s unknown)

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.

19.5 Run Groovy Scripts


Wi th the runGroovyScri pt comma nd you ca n run Groovy s cri pts from wi thi n OntoBroker a nd perform a ny
opera ti ons us i ng the Ontol ogyMa na ger. The Groovy s cri pt mus t be l oca ted i n the groovy s ubdi rectory of the
extens i ons di rectory.

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:

Variable name Description

ontol ogyMa na ger The i ns ta nce of org.s ema nti cweb.ka on2.a pi .Ontol ogyMa na ger

l og Log4j Logger l oggi ng i nto the ca tegory [DATAMODEL]

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

query Cl os ure to execute query


It ta kes one or two a rguments : query(queryText) or query(ontol ogy,queryText). The
ontol ogy a rgument mus t be ei ther a n Ontol ogy, Term or Stri ng object, s peci fyi ng the
ontol ogy di rectl y, by modul e, or by ontol ogyURI res pecti vel y.
Exa mpl e:
query("?- ?X::?Y@?M.").ea ch { pri ntl n i t.X,i t.Y,i t.M }

19.6 Query Client

Query Client (query.cmd/query.sh)


The query cl i ent a l s o s upports s peci fyi ng a query fi l e for ea s i er ha ndl i ng of mul ti l i ne queri es :
query.cmd -qf myQueryFile.obl
or
query.cmd -queryFile myQueryFile.obl

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

In thi s ca s e you get


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
madrid Location
newyork Location
h1 Location

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.

Tool for Performance Benchmarks: (benchmark cmd / sh)


OntoBroker ha s a bui l t-i n tool for mea s uri ng query ti mes , whi ch i s a n i mporta nt ta s k when des i gni ng or
opti mi zi ng a n a ppl i ca ti on. A typi ca l us e-ca s e i s to fi nd the bes t confi gura ti on for your a ppl i ca ti on by
compa ri ng di fferent query eva l ua ti on methods . Or you mi ght wa nt to di s cover regres s i on probl ems i n your
a ppl i ca ti on. In thi s ca s e you ca n execute the benchma rks regul a rl y a nd compa re them wi th ea ch other. The
res ul ts of a benchma rk run ca n be vi ewed i n a gra phi ca l report or i n a textua l output fi l e. Bel ow there i s a n
exa mpl e of a gra phi ca l report wi th s ome s ui tes i n di fferent confi gura ti ons .

Benchma rk reports a re crea ted i n s ub di rectori es of benchma rk.xml

1. Configure your benchmarks


Crea te a benchma rk confi gura ti on fi l e wi th the XML s tructure s hown bel ow. You mi ght reus e the provi ded
exa mpl e fi l e benchma rk/benchma rk.xml .

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: Inline query file! -->


<queryfile>@{options[skipSendingAnswers]} ?- closure(?X,?Y,?Z).</queryfile>
<configurations>

<!-- 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" />

<!-- New: Inline config file! -->


<configuration name="DF2">
OntologyLanguage = ObjectLogic
Storage=RAM.AVL.Packed
EvaluationMethod=DynamicFiltering2</configuration>
</configurations>
</suite>

<!-- ====================================================
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

2. Execute your benchmarks


The s ta rtup s cri pt "benchma rk.cmd" (res p. "benchma rk.s h" for Li nux/Uni x) - l oca ted a t
[Ontobroker_HOME\tool s ] - executes the benchma rks a nd s tores the res ul ts i n a gi ven output di rectory. The
fol l owi ng a rguments a re a l l owed:

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

3. Look at the benchmark results


The benchma rk res ul ts ca n be found i n the gi ven output di rectory: As a s i mpl e text fi l e res ul ts .txt or a s a HTML
report di a gra ms _benchma rk/benchma rk.html (i n conjuncti on wi th the res ul ts da ta ba s e benchma rkda ta .h2.db,
tha t conta i ns the res ul ts of a l l benchma rk runs for hi s tori ca l compa ri s ons ).
Scri pt l oca ti on:
Wi ndows : tool s \benchma rk.cmd
Li nux: tool s /benchma rk.s h

Tool to convert files


Thi s comma ndl i ne tool a l l ows fi l es to be converted from one ontol ogy forma t to a nother. Convers i ons from
a nd to ObjectLogi c, OWL a nd RDF(S) a re s upported. The opti ons a re:
convert [-fenc <ENCODING>] [-all] <inputFile> <outputFile>
Converti ng a fi l e from ObjectLogi c to OWL ca n be done vi a
tools\convert.cmd -fenc UTF-8 examples/objectlogic/travel.obl travel.owl
or
convert.cmd -fenc UTF-8 ../examples/objectlogic/travel.obl travel.owl

Note:
The output forma t i s gi ven by the ta rget fi l ena me.

Scri pt l oca ti on:


Wi ndows : tools\convert.cmd
Li nux: tools/convert.sh

208
OntoBroker 6.3 OntoBroker Tool s

Tool for checking NamesGround compliance


Thi s tool l oa ds a n ontol ogy a nd checks va ri ous properti es of the rul es (i f a l l rul es a re bottomup eva l ua bl e,
the number of rul es , a nd s o on). It a l s o checks i f you ca n s a fel y us e the confi gura ti on opti ons
"ConceptNa mes Ground", "Attri buteNa mes Ground", or "Modul eNa mes Ground". Us a ge:
checkontology <file>
You s houl d a l wa ys execute thi s tool a fter you ha ve cha nged the rul es . Thi s hel ps to detect pos s i bl e probl ems
a s ea rl y a s pos s i bl e.
Scri pt l oca ti on:
Wi ndows : tools\checkfornamesgroundsafety.cmd
Li nux: tools/checkfornamesgroundsafety.sh

Tool to dump list with built-ins


Thi s tool dumps a l l bui l t-i ns a va i l a bl e i n OntoBroker for the current confi gura ti on.
Scri pt l oca ti on:
Wi ndows : tools\logbuiltins.cmd
Li nux: tools/logbuiltins.sh

Tool to compact H term store


If you us e H2 a s s tora ge, you ca n us e thi s tool to remove unus ed, i .e. no l onger us ed terms from the
da ta model .

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 .

Tool to execute comma nds


Us e thi s s cri pt to execute comma nds di rectl y from the comma nd l i ne.
Wi ndows :
command.cmd [-h <host>] [-p <port>] <command>
Li nux:
./command.sh [-h <host>] [-p <port>] <command>
Exa mpl e:
command.cmd "commands"

Tool to execute queries


Us e thi s s cri pt to execute queri es di rectl y from the comma nd l i ne.
Wi ndows :
query.cmd [-p <port>] <querytext>
Li nux:
./query.sh [-p <port>] <querytext>
Exa mpl e:
query.cmd "?- $module(?M)."

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

21.1.1 Rules and Queries


Rul es , queri es , a nd cons tra i nts a re not s upported by the RDF Schema .

21.1.2 RDF Schema to ObjectLogic


Tra ns formi ng the RDF Schema i nto ObjectLogi c i s , i n mos t ca s es , a na l ogous to the i nvers e tra ns forma ti on. IRIs
us i ng the res erved na mes pa ce 'obl :term#' a re ma pped to the encoded ObjectLogi c term:
<obl:term#%3Cmyns:myFunction%3E(arguments)> <=> <myns:myFunction>(arguments)
If a term ca nnot be encoded due to i nva l i d ObjectLogi c s ynta x the IRI i s kept.
A s umma ry l og i s provi ded for every tra ns forma ti on. It s hows potenti a l tra ns forma ti on probl ems l i ke i s s ues
rel a ted to doma i n/ra nge a mbi gui ty.

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"].

21.1.3 ObjectLogic to OWL


The tra ns forma ti on tra ns l a tes ObjectLogi c fa cts to OWL a xi oms . P-a toms (l i tera l s ), queri es a nd cons tra i nts a re
not s upported. Axi oms whi ch a re uns upported or conta i n uns upported pa rts a re i gnored. Rul es a re a re not
s upported.

Transforming Concepts, Properties and Individuals


ObjectLogi c does not expl i ci tl y di ffer between concepts , properti es a nd i ndi vi dua l s . Any term ca n be us ed a s
one of thes e enti ty types .
On the other ha nd, OWL s tri ctl y typi fi es enti ti es wi thi n a xi oms ; enti ti es a re i denti fi ed by URIs . The a xi oms to
be crea ted ca n thereby depend on the enti ty type, e.g. i f a doma i n i s s peci fi ed for a property, i t needs to be
a n ObjectPropertyDoma i n i f the enti ty i s a n object property, but a Da ta PropertyDoma i n i f the property i s a da ta

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.

Transforming ObjectLogic Terms to OWL Entities


A gi ven ObjectLogi c term i s tra ns formed to a n OWL enti ty a s fol l ows :
If the term i s a n ri f:i ri cons ta nt, the i ri i s us ed a s enti ty URI.
Otherwi s e, the term i s forma tted a s ObjectLogi c s tri ng L a nd the URI for the enti ty i s obl :term#E, where E
i s the URL-encoded vers i on of L.

Constraints versus deriving Knowledge


In ObjectLogi c mos t of the s chema fa cts a re ha ndl ed a s cons tra i nts a nd wi l l thereby not a ffect the deri ved
fa cts but ma y jus t ma ke the ontol ogy i ncons i s tent. E.g. 'A[p{1:1}*=>B]' together wi th 'a :A', 'a [p->b]' a nd 'a [p->c]'
form a n i ncons i s tent ontol ogy, but do not deri ve tha t 'b' a nd 'c' need to be the s a me.
In OWL on the other ha nd, from 'SubCl a s s Of(A ObjectExa ctCa rdi na l i ty(1 p B))' together wi th 'Cl a s s As s erti on(A
a )', 'ObjectPropertyAs s erti on(p a b)' a nd 'ObjectPropertyAs s erti on(p a c)' i t fol l ows tha t 'b' a nd 'c' mus t be the
s a me i ndi vi dua l .
The s ema nti c di fference between cons tra i nts on the one ha nd a nd deri ved knowl edge on the other ha nd i s
i gnored by the tra ns forma ti on, i .e. the tra ns forma ti on ha ndl es the ObjectLogi c s chema fa cts a s i f they woul d
a ctua l l y a dd to the knowl edge ra ther tha n jus t bui l di ng cons tra i nts .

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.

21.1.4 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 . For s chema fa cts whi ch conta i ns properti es , property doma i n a nd property ra nge fa cts mi ght be
crea ted.
a:A. => ClassAssertion(A a)

a[p->b]. => ObjectPropertyAssertion(p a b) respectively


DataPropertyAssertion(p a b) respectively AnnotationAssertion(p a b)
a[_comment->"text"{en}]. => AnnotationAssertion(rdfs:comment a "text"@en)
a[_representation ->"text"{en}]. => AnnotationAssertion(rdfs:label a "text"@en)
a[_synonym("en")->"text"]. => AnnotationAssertion(<obl:reserved:synonym> a
"text"@en)

A[]. => Declaration(Class(A))

B::A. => SubClassOf(B A)


p<<q. => SubPropertyOf(p q)

A[p{inverseOf(q)}*=>B]. => InverseObjectProperties(p q)


A[p{symmetric}*=>()]. => SymmetricObjectProperty(p)

212
OntoBroker 6.3 Appendi x

A[p{transitive}*=>()]. => TransitiveObjectProperty(p)

A[p{n:*}*=>()]. => SubClassOf(A ObjectMinCardinality(n p))


respectively SubClassOf(A DataMinCardinality(n p))
A[p{0:n}*=>()]. => SubClassOf(A ObjectMaxCardinality(n p))
respectively SubClassOf(A DataMaxCardinality(n p))
for n ? 1
. => FunctionalObjectProperty(p) respectively
FunctionalDataProperty(p)
for n = 1

A[p*=>B]. => ObjectPropertyDomain(p A),


ObjectPropertyRange(p B)
A[p*=>_string]. => DataPropertyDomain(p A), DataPropertyRange(p
xsd:string)

Domain and Range

OWL OWL-in-ObjectLogic ObjectLogic


Loca l Ra nge SubCl a s s Of(:Pers on Pers on::_Al l Va l ues From Pers on
Speci fi ca ti on ObjectAl l Va l ues From(: (ha s Mother, Woma n) [ha s Mother*=>Woma n]
ha s Mother :Woma n))

Compa ri ng Property SubCl a s s Of(:Pers on Pers on::_Al l Va l ues From Pers on


Type Decl a ra ti ons ObjectAl l Va l ues From(: (ha s Mother, Woma n) [ha s Mother*=>Woma n]
ha s Mother :Woma n))
_Decl a ra ti on Impl i ci t property type
Property type (ha s Mother, decl a ra ti on by ra nge
decl a ra ti on by ea ch us e owl #ObjectProperty) onl y
Property type
decl a ra ti on per ontol ogy

Gl oba l Ra nge ObjectPropertyDoma i n(: ObjectPropertyDoma i n(: Pers on


Speci fi ca ti on ha s Mother :Pers on), ha s Mother :Pers on), [ha s Mother*=>Woma n]
ObjectPropertyRa nge(: ObjectPropertyRa nge(:
ha s Mother :Woma n) ha s Mother :Woma n) Impl i ci t property type
decl a ra ti on by ra nge
onl y

One Doma i n, no ObjectPropertyDoma i n(: Pers on


Ra nge ha s Mother :Pers on) [ha s Mother*=>rdfs #Res o
urce]
Doma i n: Pers on
Doma i n: Pers on
Ra nge: a nythi ng
Ra nge: fi l l er
rdfs #Res ource (wi thout
a ny s peci a l mea ni ng)

No Doma i n, one ObjectPropertyRa nge(: owl #Thi ng


Ra nge ha s Mother :Woma n) [ha s Mother*=>Woma n]
Doma i n: a nythi ng Doma i n: fi l l er owl #Thi ng
(wi thout a ny s peci a l
Ra nge: Woma n mea ni ng)
Ra nge: Woma n

One Doma i n, one ObjectPropertyDoma i n(: Pers on


Ra nge ha s Mother :Pers on), [ha s Mother*=>Woma n]
ObjectPropertyRa nge(:
ha s Mother :Woma n)

One Doma i n, mul ti pl e ObjectPropertyDoma i n(: Pers on


Ra nges ha s Mother :Pers on), [ha s Mother*=>Woma n],

213
OntoBroker 6.3 Appendi x

ObjectPropertyRa nge(: Pers on


ha s Mother :Woma n), [ha s Mother*=>Mother]
ObjectPropertyRa nge(:
ha s Mother :Mother)

Uni on of Doma i ns , ObjectPropertyDoma i n(: Ma n


one Ra nge ha s Mother [ha s Mother*=>Woma n],
ObjectUni onOf(:Ma n : Woma n
Woma n)), [ha s Mother*=>Woma n]
ObjectPropertyRa nge(:
ha s Mother :Woma n)

Uni on of Doma i ns , ObjectPropertyDoma i n(: Ma n


di fferent l oca l Ra nges ha s Mother [ha s Mother*=>Woma n],
ObjectUni onOf(:Ma n : Woma n
Woma n)), [ha s Mother*=>Mother]
SubCl a s s Of(:Ma n
ObjectAl l Va l ues From(:
ha s Mother :Woma n)),
SubCl a s s Of(:Woma n
ObjectAl l Va l ues From(:
ha s Mother :Mother))

Mul ti pl e Doma i ns , ObjectPropertyDoma i n(: Crea ture


one Ra nge ha s Mother :Crea ture), [ha s Mother*=>Woma n],
ObjectPropertyDoma i n(: Pers on
ha s Mother :Pers on), [ha s Mother*=>Woma n]
ObjectPropertyRa nge(:
Doma i n: uni on of
ha s Mother :Woma n)
Crea ture a nd Pers on
Doma i n: i nters ecti on of
Crea ture a nd Pers on Ra nge: Woma n
Retra ns formed l i ke
Ra nge: Woma n
‘Uni on of Doma i ns , one
Ra nge‘

Mul ti pl e Doma i ns , ObjectPropertyDoma i n(: Crea ture


mul ti pl e Ra nges ha s Mother :Crea ture), [ha s Mother*=>Woma n],
ObjectPropertyDoma i n(: Crea ture
ha s Mother :Pers on), [ha s Mother*=>Mother],
ObjectPropertyRa nge(: Pers on
ha s Mother :Woma n), [ha s Mother*=>Woma n],
ObjectPropertyRa nge(: Pers on
ha s Mother :´Mother) [ha s Mother*=>Mother]
Doma i n: i nters ecti on of Doma i n: uni on of
Crea ture a nd Pers on Crea ture a nd Pers on
Ra nge: i nters ecti on of Ra nge: i nters ecti on of
Woma n a nd Mother Woma n a nd Mother
Retra ns formed l i ke
‘Uni on of Doma i ns ,
di fferent l oca l Ra nges ‘

21.1.5 OWL to ObjectLogic


The tra ns forma ti on tra ns l a tes OWL a xi oms to ObjectLogi c fa cts . SWRL rul es a re not s upported a t a l l . Axi oms
whi ch a re uns upported or conta i n uns upported pa rts a re i gnored.

Transforming named OWL Entities to ObjectLogic Terms


A na med OWL enti ty i s tra ns l a ted to a n ObjectLogi c term by crea ti ng a cons ta nt of type ri f:i ri whi ch cons i s ts of
the URI of the enti ty. There i s one excepti on: i f the URI of the enti ty s ta rts wi th 'obl :term#' then the l oca l pa rt

214
OntoBroker 6.3 Appendi x

of the URI i s a s s umed to be the (URL-encoded) ObjectLogi c s eri a l i za ti on of a term whi ch wi l l be pa rs ed a nd


us ed i ns tea d of a ri f:i ri cons ta nt.

Object Property Expressions


The i nvers e object property expres s i on i s uns upported.

Data Ranges
Da ta ra nges bes i des pl a i n da ta types a re uns upported.

21.1.6 Complex Class Expressions


A s ubs et of compl ex cl a s s expres s i ons i s s upported i f us ed a s a s uper des cri pti on wi thi n a s ub cl a s s a xi om,
but no where el s e. Recurs i ve compl ex cl a s s expres s i ons 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.

ObjectPropertyAssertion(q a b) => a[q->b].


DataPropertyAssertion(q a "text"@en) => a[q->"text"{en}.
AnnotationAssertion(q a b) => a[q->b].
AnnotationAssertion(rdfs:comment a "text"@en) => a[_comment->"text"{en}].
AnnotationAssertion(rdfs:label a "text"@en) => a[_representation ->"text"{en}]
AnnotationAssertion(<obl:reserved:synonym> a "text"@en)
=> a[_synonym("en")->"text"].

Declaration(Class(A)) => A[].

SubClassOf(B A) => B::A.

InverseObjectProperties(p r) => A[p{inverseOf(r)}*=>B].


SymmetricObjectProperty(p) => A[p{symmetric}*=>()].
TransitiveObjectProperty(p) => A[p{transitive}*=>()].

SubClassOf(A ObjectMinCardinality(1 p)) => A[p{1:*}*=>()].


SubClassOf(A DataMinCardinality(1 p)) => A[p{1:*}*=>()].
SubClassOf(A ObjectMaxCardinality(1 p)) => A[p{0:1}*=>()].
SubClassOf(A DataMaxCardinality(1 p)) => A[p{0:1}*=>()].

{A domain of p, B range of p} => A[p*=>B].

21.1.7 OWL2 (RL) in ObjectLogic

Predefined and Named Classes

215
OntoBroker 6.3 Appendi x

Language OWL2 Functional Syntax1 ObjectLogic Syntax


Feature
RDF Syntax2

na med cl a s s CN CN
CN

uni vers a l cl a s s owl :Thi ng owl :Thi ng for ObjectLogi c


owl :Thi ng

empty cl a s s owl :Nothi ng owl :Nothi ng for ObjectLogi c


owl :Nothi ng

1 Second col umn, upper pa rt: OWL2 Functi ona l Synta x


2 Second col umn, l ower pa rt: RDF Synta x

Boolean Connectives and Enumeration of Individuals

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

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

uni on ObjectUni onOf(C1 … Cn) _Uni onOf([C1, … Cn])


_:x rdf:type owl :Cl a s s .
_:x owl :uni onOf ( C1 … Cn ).

compl ement ObjectCompl ementOf(C) _Compl ementOf(C)


_:x rdf:type owl :Cl a s s .
_:x owl :compl ementOf C.

enumera ti on ObjectOneOf(a 1 … a n) _OneOf([a 1, …, a n])


_:x rdf:type owl :Cl a s s .
_:x owl :oneOf ( a 1 … a n ).

216
OntoBroker 6.3 Appendi x

Object Property Restrictions

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

uni vers a l ObjectAl l Va l ues From(P C) _Al l Va l ues From(P, C)


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :a l l Va l ues From C

exi s tenti a l ObjectSomeVa l ues From(P C) _SomeVa l ues From(P, C)


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :s omeVa l ues From C

i ndi vi dua l va l ue ObjectHa s Va l ue(P a ) _Ha s Va l ue(P, a )


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :ha s Va l ue a .

l oca l refl exi vi ty ObjectHa s Sel f(P) _Ha s Sel f(P)


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty P.
_:x owl :ha s Sel f "true"^^xs d:bool ea n.

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.

qua l i fi ed ObjectMa xCa rdi na l i ty(n P C) _Ma xCa rdi na l i ty(n, P, C)


ma xi mum
_:x rdf:type owl :Res tri cti on.
ca rdi na l i ty
_:x owl :onProperty P.
_:x owl :ma xQua l i fi edCa rdi na l i ty n.
_:x owl :onCl a s s C.

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.

qua l i fi ed ObjectMi nCa rdi na l i ty(n P C) _Mi nCa rdi na l i ty(n, P, C)


mi ni mum
_:x rdf:type owl :Res tri cti on.
ca rdi na l i ty
_:x owl :onProperty P.
_:x owl :mi nQua l i fi edCa rdi na l i ty n.

217
OntoBroker 6.3 Appendi x

_:x owl :onCl a s s C.

218
OntoBroker 6.3 Appendi x

Data Property Restrictions

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

uni vers a l Da ta Al l Va l ues From(R D) _Al l Va l ues From(R, D)


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :a l l Va l ues From D.

exi s tenti a l Da ta SomeVa l ues From(R D) _SomeVa l ues From(R, D)


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :s omeVa l ues From D.

l i tera l va l ue Da ta Ha s Va l ue(R v) _Ha s Va l ue(R, v)


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperty R.
_:x owl :ha s Va l ue v.

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.

qua l i fi ed Da ta Ma xCa rdi na l i ty(n R D) _Ma xCa rdi na l i ty(n, R, D)


ma xi mum
_:x rdf:type owl :Res tri cti on.
ca rdi na l i ty
_:x owl :onProperty R.
_:x owl :ma xQua l i fi edCa rdi na l i ty n.
_:x owl :onDa ta Ra nge D.

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.

qua l i fi ed Da ta Mi nCa rdi na l i ty(n R D) _Mi nCa rdi na l i ty(n, R, D)


mi ni mum
_:x rdf:type owl :Res tri cti on.
ca rdi na l i ty
_:x owl :onProperty R.
_:x owl :mi nQua l i fi edCa rdi na l i ty n.
_:x owl :onDa ta Ra nge D.

219
OntoBroker 6.3 Appendi x

Restrictions Using n-ary Data Range


In the fol l owi ng ta bl e 'Dn' i s a n n-a ry da ta ra nge.

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

n-a ry uni vers a l 1 Da ta Al l Va l ues From(R1 … Rn Dn) not s upported


_:x rdf:type owl :Res tri cti on.
_:x owl :onProperti es ( R1 … Rn ).
_:x owl :a l l Va l ues From Dn.

n-a ry Da ta SomeVa l ues From(R1 … Rn Dn) not s upported


exi s tenti a l 1
_:x rdf:type owl :Res tri cti on.
_:x owl :onProperti es ( R1 … Rn).
_:x owl :s omeVa l ues From Dn.
1 Uns upported by OWL API a nd thus uns upported i n ObjectLogi c.

Properties

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

na med object PN PN
property PN

uni vers a l object owl :topObjectProperty owl #topObjectProperty


property owl :topObjectProperty

empty object owl :bottomObjectProperty owl #bottomObjectProperty


property owl :bottomObjectProperty

ObjectInvers eOf(PN) _Invers eOf(PN)


i nvers e property
_:x owl :i nvers eOf PN

Data Property Expressions

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

na med da ta R R
property
R

uni vers a l da ta owl :topDa ta Property owl :#topDa ta Property


property
owl :topDa ta Property

empty da ta owl :bottomDa ta Property owl :#bottomDa ta Property


property
owl :bottomDa ta Property

220
OntoBroker 6.3 Appendi x

Individuals & Literals

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

na med aN
i ndi vi dua l
aN

a nonymous _:a _#‘a ‘


i ndi vi dua l 1
_:a

l i tera l (da ta type "a bc"^^DN "a bc"^^DN


va l ue)
"a bc"^^DN
1 The s ema nti cs of a nonymous i ndi vi dua l s i s not s upported by OntoBroker, i ns tea d a nonymous i ndi vi dua l s
a re ma pped to uni que i ds on i mport.

Data Ranges

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

na med da ta type DN DN
DN

da ta ra nge Da ta Compl ementOf(D) _Compl ementOf(D)


compl ement
_:x rdf:type rdfs :Da ta type.
_:x owl :da ta typeCompl ementOf D.

da ta ra nge Da ta Inters ecti onOf(D1…Dn) _Inters ecti onOf([D1, D2, …,Dn])


i nters ecti on
_:x rdf:type rdfs :Da ta type.
_:x owl :i nters ecti onOf (D1…Dn).

da ta ra nge Da ta Uni onOf(D1…Dn) _Uni onOf([D1, … ,Dn])


uni on
_:x rdf:type rdfs :Da ta type.
_:x owl :uni onOf (D1…Dn).

l i tera l Da ta OneOf(v1 … vn) _OneOf([v1, … ,vn])


enumera ti on
_:x rdf:type rdfs :Da ta type.
_:x owl :oneOf ( v1 … vn ).

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

Class Expression Axioms

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

s ubcl a s s SubCl a s s Of(C1 C2) C1::C2


C1 rdfs :s ubCl a s s Of C2.

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.

equi va l ent Equi va l entCl a s s es (C1 … Cn) _Equi va l entCl a s s es 1([C1,…, Cn ])


cl a s s es
Cj owl :equi va l entCl a s s Cj+1. j=1…n-1

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

Object Property Axioms

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

s ubproperty SubObjectPropertyOf(P1 P2) P1 << P2


P1 rdfs :s ubPropertyOf P2.

property cha i n SubObjectPropertyOf _ PropertyCha i n([P1, P2, …,Pn])


i ncl us i on (ObjectPropertyCha i n(P1 … Pn) P)
P owl :propertyCha i nAxi om (P1 … Pn).

property doma i n ObjectPropertyDoma i n(P C) C[P*=>rdfs #Res ource]


P rdfs :doma i n C.

property ra nge ObjectPropertyRa nge(P C)


P rdfs :ra nge C.

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.

functi ona l Functi ona l ObjectProperty(P) owl #Thi ng[P{0:1}*=>()]


property
P rdf:type owl :Functi ona l Property.

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.

s ymmetri c Symmetri cObjectProperty(P) owl #Thi ng [P {s ymmetri c} *=> ()].


property
P rdf:type owl :Symmetri cProperty.

a s ymmetri c As ymmetri cObjectProperty(P) owl #Thi ng [P {a s ymmetri c} *=> ()].


property
P rdf:type owl :As ymmetri cProperty.

tra ns i ti ve Tra ns i ti veObjectProperty(P) owl #Thi ng [P {tra ns i ti ve} *=> ()].


property
P rdf:type owl :Tra ns i ti veProperty.

223
OntoBroker 6.3 Appendi x

Data Property Axioms

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

s ubproperty SubDa ta PropertyOf(R1 R2) R1 << R2


R1 rdfs :s ubPropertyOf R2.

property doma i n Da ta PropertyDoma i n(R C) C[R*=>rdfs #Res ource]


R rdfs :doma i n C.

property ra nge Da ta PropertyRa nge(R D) owl #Thi ng[R*=>D]


R rdfs :ra nge D.

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

functi ona l Functi ona l Da ta Property(R)


property
R rdf:type owl :Functi ona l Property.

Datatype Definitions

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

da ta type Da ta typeDefi ni ti on(DN D) _Da ta typeDefi ni ti on(DN, D)


defi ni ti on
DN owl :equi va l entCl a s s D.

224
OntoBroker 6.3 Appendi x

Assertions

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

i ndi vi dua l Sa meIndi vi dua l (a 1 … a n) _Sa meIndi vi dua l (a 1, a 2)


equa l i ty
a j owl :s a meAs a j+1. j=1…n-1 _Sa meIndi vi dua l 1([a 1 … a n])

i ndi vi dua l Di fferentIndi vi dua l s (a 1 a 2) _Di fferentIndi vi dua l s (a 1, a 2)


i nequa l i ty
a 1 owl :di fferentFrom a 2.

pa i rwi s e Di fferentIndi vi dua l s (a 1 … a n) _Di fferentIndi vi dua l s 1([a 1 … a n])


i ndi vi dua l
_:x rdf:type owl :Al l Di fferent.
i nequa l i ty
_:x owl :members (a 1 … a n).

cl a s s a s s erti on Cl a s s As s erti on(C a ) a :C


a rdf:type C.

pos i ti ve object ObjectPropertyAs s erti on( PN a 1 a 2 ) a 1[PN ->a 2]


property
a 1 PN a 2.
a s s erti on

pos i ti ve da ta Da ta PropertyAs s erti on( R a v ) a [R ->v]


property
a R v.
a s s erti on

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

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

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

Language OWL2 Functional Syntax ObjectLogic Syntax


Feature
RDF Syntax

cl a s s Decl a ra ti on( Cl a s s ( CN ) ) CN[].

CN rdf:type owl :Cl a s s .

da ta type Decl a ra ti on( Da ta type( DN ) ) DN:owl #Da ta typeProperty

DN rdf:type rdfs :Da ta type.

object property Decl a ra ti on( ObjectProperty( PN ) ) PN:owl #ObjectProperty

PN rdf:type owl :ObjectProperty.

da ta property Decl a ra ti on( Da ta Property( R ) ) R:owl #Da ta Property

R rdf:type owl :Da ta typeProperty.

a nnota ti on Decl a ra ti on( Annota ti onProperty A:owl #Annota ti onProperty


property (A))

A rdf:type owl :Annota ti onProperty.

na med Decl a ra ti on( Na medIndi vi dua l a N: owl :Na medIndi vi dua l


i ndi vi dua l ( aN ) )
a N rdf:type owl :Na medIndi vi dua l .

21.2 Throughput Benchmark


The Throughput Benchma rk i s pa ra meteri zed by a benchma rk confi gura ti on fi l e. An exa mpl e i s l oca ted i n the
OntoBroker i ns ta l l a ti on di rectory:
benchmark\benchmark-throughput.xml.
Ea ch s ui te ha s 2 throughput properti es for confi guri ng the benchma rk:
<suite name="Threads-10" threads="10" rounds="50">
The fi l e benchma rk.dtd hel ps to crea te va l i d benchma rk.xml fi l es , i f your xml edi tor s upports dtd va l i da ti on.
threa ds : Number of threa ds to execute queri es . Thi s i s the number of cl i ents whi ch execute pa ra l l el
queri es .
rounds : Number of queri es executed by ea ch threa d.
In the exa mpl e a bove, ea ch of the 10 threa ds execute 50 queri es , whi ch mea ns tha t 500 queri es a re executed.
The benchma rk di a gra ms s how the throughput, whi ch mea ns how ma ny queri es a re executed per s econd.
Throughput i s the number of queri es executed ea ch ti me. La tency i s the ti me a query needs to run.

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.3 Range-Restricted Rules


OntoBroker i mpl ements nega ti on a s the s o-ca l l ed "defa ul t nega ti on" (OntoBroker s upports both s tra ti fi ed
a nd wel l founded nega ti on). Thi s mea ns tha t when you ha ve the progra m:
q(a).
q(b).
r(a).
QUERY q1: ?- q(?X) AND NOT r(?X).
Then OntoBroker eva l ua tes the rul e a s fol l ows :
1. Retri eve a l l tupl es for q(X): X=a , X=b
2. Retri eve a l l tupl es for r(X): X=a
3. Subtra ct the tupl es r(X) from q(X).
So the res ul t of the query i s "X=b" beca us e b does not occur i n r(X) a nd hence the formul a "NOT r(X)" i s true.
Ima gi ne wha t woul d ha ppen i f we ha d the progra m:
q(a).
q(b).
r(a).
QUERY q1: ?- NOT r(?X).
We ha ve nothi ng a s the ba s e where we coul d s ubtra ct the r(X) fa cts from. So the res ul t woul d be i nfi ni tel y
l a rge (= the res ul t s i ze i s not ra nge res tri cted).

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

Name Arity Description Parameters Bindings


"_a bs " 2 a bs ol ute doubl e va l ue ["i nput","a bs ol ute va l ue"] bf;fb;bb;

"_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 ggrega ti ons " 4 returns a l l a va i l a bl e ["na me","number of i nput


a ggrega ti ons va ri a bl es ","des cri pti on","i nput
va ri a bl es "]

"_a ppend" 3 a ppends s econd to fi rs t l i s t ["fi rs t l i s t","s econd l i s t","merged


l i s t"]

"_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

"_bound" 1 Tes ts i f i nput i s bound (i .e. ["va ri a bl e"]


equa l s NULL va l ue).

"_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 "]

"_cei l i ng" 2 Returns the s ma l l es t (cl os es t ["number","ma thema ti ca l i nteger bf;bb;


to nega ti ve i nfi ni ty) va l ue tha t (doubl e or deci ma l )"]
i s l es s tha n or equa l to the
a rgument a nd i s equa l to a
ma thema ti ca l i nteger

"_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;

"_concepts " 2 return concepts ["concept","modul e"] ff;bf;fb;bb;ff;

"_connectors " 4 returns a l l a va i l a bl e ["na me","a ri ty","des cri pti on","l i s t


connectors of pa ra meter na mes "]

"_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

"_conta i ns Term" 2 i s term conta i ned i n a nother ["term","conta i nedTerm"] bb;


term (functi ona l term)

"_currentDa teTi me" 1 returns the current da te ti me ["currentDa teti me"] f;b;

"_currentUs er" 1 returns current l ogi n us er a s ["us er"]


IRI (a nd onl y i f confi g
pa ra meter Securi ty.
Acces s Control = on) f;b;f;

"_cut" 3 Returns a s ubs tri ng of the ["content","offs et","res ul t"]


s tri ng-object trunca ted by the
number of cha ra cters
s peci fi ed i n the method bbf;bbb;
a rgument. Trunca ti on ta kes
pl a ce on the ri ght.

"_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.

"_da y" 2 returns da y ["da te/da teti me","da y (i nteger)"]

"_da ys " 2 returns da ys ["dura ti on","da ys (i nteger)"] bf;bb;

"_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

returns the pos i ti on of the tDi ffence"]


fi rs t not ma tchi ng cha ra cter
bbf;bbb;

"_di fference" 3 Crea tes di fference of two ["ma p1","ma p2","res ul t ma p"]
ma ps

"_ebv" 1 Genera tes the effecti ve ["va l ue"]


bool ea n va l ue.

"_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;

"_equa l s " 2 equa l s compa ri s on (l eft == ["l eft","ri ght"] bb;


ri ght)

"_fa l s e" 0 a l wa ys returns fa l s e []


Exa mpl e:
?- _'fa l s e'. // s i ngl e quotes
needed a s fa l s e i s keyword i n
ObjectLogi c

"_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;

"_fi l ter" 2 fi l ters va l ues ["va ri a bl e","ri ght"] bb;

"_fi l terN" 2 fi l ters va l ues ["va ri a bl e","ri ght"]

bb;

"_fi l terdups " 2 s tores the l i s t a nd i s true i f ["va ri a bl e


l i s t i s not a dupl i ca te i ns ta nti a ti ons ","provena nce
l i s t"]

"_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;

"_fl a tten" 2 fl a ttens a l i s t of l i s ts i nto a ["l i s t of l i s ts ","fl a tted l i s t"]


fl a t l i s t a nd el i mi na tes
dupl i ca tes

"_fl oor" 2 Returns the l a rges t (cl os es t to ["number","ma thema ti ca l i nteger


pos i ti ve i nfi ni ty) va l ue tha t i s (doubl e or deci ma l )"]
l es s tha n or equa l to the
a rgument a nd i s equa l to a bf;bb;
ma thema ti ca l i nteger

"_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

"_genera teExpl a na ti 4 genera tes expl a na ti on ["modul e","rul eId","templ a tegro

229
OntoBroker 6.3 Appendi x

onTempl a te" templ a te for gi ven rul eId up","output"]


bbbf;bbbb;

"_geoDi s ta nce" 3 Ca l cul a ti on of di s ta nce ["coordi na te1


between two geogra phi c [geoCoordi na te]","coordi na te2
coordi na tes i n ki l ometer. [geoCoordi na te]","di s ta nce i n
ki l ometer [doubl e]"]

"_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,

"_ha s Forei gnRol e" 1 checks i f current us er ha s ["rol e"]


gi ven forei gn rol e. Rol es from
the
Securi tyModul eAuthori za ti onR b;
ea l m a re not checked. Thi s i s
onl y rel eva nt i f a cces s control
i s ena bl ed.

"_hos t" 2 returns hos t of IRI ["i ri ","hos t s tri ng"]

bf;bb;

"_hour" 2 returns hour ["ti me/da teti me","hour


(i nteger)"]

"_hours " 2 returns hours ["dura ti on","hours (i nteger)"]

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 nfo" 2 Retri eve i nforma ti on a bout ["key","i nfo"]


OntoBroker.
Currentl y \vers i on\
a nd \ful l Vers i on\ a re
s upported

"_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 Bl a nk" 1 Tes ts i f i nput i s a bl a nk node. ["va l ue"]

"_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 a cces s control i s ena bl ed.

"_i s Da ta type" 1 checks i f object i s a da ta type ["typena me"] b;

"_i s IRI" 1 Tes ts i f i nput i s a n IRI. ["va l ue"]

"_i s Li tera l " 1 Tes ts i f i nput i s a RDF l i tera l . ["va l ue"]

"_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.

"_i s Nul l " 1 checks i f object i s the nul l ["term"]


va l ue

b;

"_i s Permi tted" 1 checks i f current us er ha s ["permi s s i on"]


gi ven permi s s i on. Thi s i s onl y
rel eva nt i s a cces s control i s
ena bl ed. b;

"_i s PropertyPermi tte 2 checks i f current us er ha s ["property","a cces s Ri ght"]


d" a cces s ri ght for property. Thi s
i s onl y rel eva nt i s a cces s
control i s ena bl ed.

"_i s Query" 2 true i f gi ven i d i s a query ["modul e","queryID"] bf;bb;

"_i s Rul e" 2 true i f gi ven i d i s a rul e ["modul e","rul eID"]

bf;bb;

"_i s TypeOf" 2 checks i f object i s of gi ven ["typena me","object"]


type

fb;bb;

"_i s equa l " 2 X i s equa l Y ["X","Y"]

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 a ti tude" 2 Get the l a ti tude of a ["coordi na te


geogra phi ca l coordi na te. [geoCoordi na te]","l a ti tude
[doubl e]"]

"_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;

"_l es s OrEqua l s " 2 l es s tha n or equa l s ["l eft","ri ght"]


compa ri s on (l eft <= ri ght)

bb;

"_l es s OrEqua l s N" 2 l es s tha n or equa l s ["l eft","ri ght"]


compa ri s on (l eft <= ri ght)

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

"_l ongi tude" 2 Get the l ongi tude of a ["coordi na te


geogra phi ca l coordi na te. [geoCoordi na te]","l ongi tude
[doubl e]"]

"_ma p2ta bl e" 4 Converts ma ps to fl a t ta bl e ["ma p","pa th


s tri ng","pos i ti on","res ul t va l ue"]

"_ma tch" 2 Y ma tches X ["X","Y"]

"_ma tch" 3 The s tri ng i n the fi rs t ["content","i nput","va ri a bl e"]


a rgument i s ma tched wi th the
regul a r expres s i on i n the
s econd a rgument. The res ul t bbf;bbb;
(thi rd a rgument) of the
method i s a l i s t of terms of
the form ma tch
(ma tchi ngPos i ti on,
ma tchi ngSubs tri ng), whi ch
repres ents ma tches i ns i de
the object-s tri ng. The l i s t i s
s orted i n the a s cendi ng order
of pos i ti ons of the ma tches .
The counti ng of pos i ti ons i n
the object s tri ng s ta rts wi th 0.

"_member" 2 _l i s t[*=> _member(_object)]. ["l i s t","object"]


Bi ndi ng: bb. The method's
a rgument a nd the l i s t-object
ma y not be ful l y ground. In bf;bb;
thi s ca s e, the method
s ucceeds , i f the a rgument to
the method uni fi es wi th a
member of the l i s t.

"_memberAt" 3 The va l ue of the method i s ["l i s t","i ndex","va l ue"]

232
OntoBroker 6.3 Appendi x

the object tha t occurs i n the


l i s t object a t the pos i ti on
bff;bbf;bfb;
gi ven by the a rgument to the
bbb;
method

"_memberByPa th" 3 Fi l ters wi th xpa th expres s i on ["ma p","pa th s tri ng","res ul t


va l ue"]

"_metri cs " 1 returns metri cs a bout the ["metri cs "]


ontol ogy ma na ger

f;b;f;

"_mi nute" 2 returns mi nute ["ti me/da teti me","mi nute


(i nteger)"]

"_mi nutes " 2 returns mi nutes ["dura ti on","mi nutes (i nteger)"]

bf;bb;

"_modul es " 1 returns the a va i l a bl e ["modul es "]


modul es

f;b;f;

"_month" 2 returns month ["da te/da teti me","month


(i nteger)"]

"_months " 2 returns months ["dura ti on","months (i nteger)"]

bf;bb;

"_mul ti pl y" 3 mul ti pl i es numbers us i ng ["fa ctor","fa ctor","product"]


doubl e a ri thmeti c

bbf;bfb;fbb;
bbb;

"_mul ti pl yDeci ma l " 3 mul ti pl i es numbers us i ng ["fa ctor","fa ctor","product"]


deci ma l a ri thmeti c

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 ze" 2 Norma l i ze order of key/va l ue ["i nput","norma l i zed"] bf;


pa i rs for _ma p i nput or
norma l i ze to UTC ti mezone for
_da teTi me, _da te or _ti me
i nput.

"_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

"_numberToNumber 4 Converts between fl oa ti ng- ["Type URI 1","Type URI


" poi nt a nd fi xed-poi nt 2","Numeri c Va l ue 1","Numeri c
numbers . Va l ue 2"]

"_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.

"_pa th" 2 returns pa th of IRI ["i ri ","pa th s tri ng"] bf;bb;

"_port" 2 returns expl i zi t port of IRI ["i ri ","port i nteger"]

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;

"_properti es " 2 return properti es ["property","modul e"]

"_query" 2 returns query of IRI ["i ri ","query s tri ng"]

"_queryByID" 3 returns query text for gi ven ID ["modul e","queryID","rul eText"] bff;bbf;bfb;
bbb;

"_queryConta i ns Ter 3 returns queryIDs for whi ch the ["modul e","term","queryID"]


m" term i s conta i ned i n the query
formul a
bbf;bbb;

"_queryInfo" 4 returns query text a nd ["modul e","queryID","rul eText","i


a ddi ti ona l i nforma ti on for nfo"]
gi ven ID

"_regex" 3 Ma tches a ga i ns t a regul a r ["va l ue","regul a r


expres s i on. expres s i on","opti ons "]

"_repl a ce" 4 Repl a ces every occurrence of ["i nput


the regul a r expres s i on i ns i de s tri ng","regexp","i nput","res ul t"]
the object s tri ng wi th the
s tri ng gi ven i n the s econd bbbf;bbbb;
a rgument of the method. The
regul a r expres s i on i s gi ven i n
the fi rs t a rgument.

"_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"]

"_rootconcepts " 2 us e the concept hi era rchy to ["concept","modul e"]


determi ne the root concepts

ff;bf;fb;bb;ff;

"_round" 2 rounds number ["number","rounded number"]

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

" term i s conta i ned ei ther i n D"]


rul e hea d or body
bbff;bbbf;
bbfb;bbbb;

"_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

"_rul eoutl ogger" 1 pri nts i nput to cons ol e ["i nput"]

"_s cheme" 2 returns s cheme of IRI ["i ri ","s cheme s tri ng"] bf;bb;

"_s econd" 2 returns s econd ["ti me/da teti me","s econd


(i nteger)"]

"_s econds " 2 returns s econds ["dura ti on","s econds (i nteger)"]

bf;bb;

"_s es s i onInfo" 1 returns i nforma ti on a bout ["i nfoMa p"]


s es s i on

"_s i gn" 2 returns s i gn ["dura ti on","s i gn (i nteger)"]

bf;bb;

"_s ort" 2 Returns s orted l i s t ["l i s t","s orted l i s t"]

bf;bb;

"_s pl i t" 3 s pl i ts before the fi rs t ["i nput


cha ra cter of regexp s tri ng","regexp","va ri a bl e"]

"_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;

"_s ta ti s ti cs Index" 2 provi des s ome s ta ti s ti cs ["modul e","s ta ti s ti cs text"]


a bout a n i ndex

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.

"_s tri ngToCons ta nt" 3 converts a l exi ca l va l ue to a ["typena me","l exi ca l


cons ta nt a nd ba ckwa rds va l ue","cons ta nt"]

"_s ubs et" 2 true i f fi rs t l i s t conta i ns a l l ["fi rs t l i s t","s econd l i s t"]


i tems of s econd l i s t

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;

"_textVa l ue" 2 Returns text pa rt of pl a i n ["pl a i n l i tera l ","text s tri ng"]


l i tera l

"_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;

"_toLower" 2 l ower ca s e of s tri ng ["s tri ng","l ower s tri ng"]

bf;bb;

"_toObjectLogi cStri n 2 returns ObjectLogi c ["object","ObjectLogi c


g" repres enta ti on repres enta ti on"]

bf;

"_toStri ng" 2 returns s tri ng repres enta ti on ["object","s tri ng repres enta ti on"]

bf;bb;

"_toType" 3 returns new i ns ta nce for gi ven ["typena me","pa ra m1","object"]


pa ra meter

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;

"_toUpper" 2 upper-ca s e of s tri ng ["s tri ng","upper s tri ng"]

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]]

"_tokeni zeRegExp" 3 s pl i ts before the fi rs t ["i nput s tri ng","regexp","token"]


cha ra cter of regexp

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

"_true" 0 a l wa ys returns true []


?- _'true'. // s i ngl e quotes
needed a s true i s keyword i n
ObjectLogi c

"_typeNa me" 2 returns da ta type of i nput ["object","typena me"]

bf;bb;

"_uni fy" 2 Uni fi es fi rs t wi th s econd ["l eft","ri ght"]


pa ra meter

bf;fb;bb;ff;

"_uni on" 3 Crea tes uni on of two ma ps ["ma p1","ma p2","res ul t ma p"]

"_us er" 2 returns us er of IRI ["i ri ","us er s tri ng"]

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)

"_wri te" 1 pri nts pa ra meters ["X1"]

237
OntoBroker 6.3 Appendi x

b;

"_wri te" 2 pri nts pa ra meters ["X1","X2"]

b;b;

"_wri te" 3 pri nts pa ra meters ["X1","X2","X3"]

b;b;b;

"_wri te" 4 pri nts pa ra meters ["X1","X2","X3","X4"]

b;b;b;b;

"_wri te" 5 pri nts pa ra meters ["X1","X2","X3","X4","X5"]

b;b;b;b;b;

"_wri te" 6 pri nts pa ra meters ["X1","X2","X3","X4","X5","X6"] b;b;b;b;b;b;

"_yea r" 2 returns yea r ["da te/da teti me","yea r


(i nteger)"]

"_yea rs " 2 returns yea rs ["dura ti on","yea rs (i nteger)"]

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;

21.4.1 Information about _queryIndex/10


The queryIndex/10 bui l t-i n executes a s ea rch i n a Lucene ful l -text i ndex. Typi ca l l y thi s i ndex i s a n
a utoma ti ca l l y ma na ged i ndex of the OntoBroker, but externa l i ndexes ca n a l s o be queri ed. The bui l t-i n ha s 10
a rguments , the fi rs t fi ve mus t be bound.

238
OntoBroker 6.3 Appendi x

Argument Bound/ Description


Free

<module> b The modul e whos e i ndex s houl d be queri ed

<option list> b Li s t of opti ona l pa ra meter (s ee l i s t bel ow for deta i l s )

<lucene query text> b The query s tri ng (Lucene query s ynta x)


s ee http://l ucene.a pa che.org/ja va /2_9_3/querypa rs ers ynta x.html
for deta i l s a bout the query s ynta x.

<offset> b Index of fi rs t hi t to return (s ta rts wi th 0)

<limit> b Ma xi ma l number of hi ts to return

<object> f Term for object hi t

<total count> f Tota l count of hi ts

<score> f Lucene ra nki ng for the hi t

<order> f Order number to s ort the hi ts i n the correct order

<optional output f Contents depends on <opti on l i s t>


list>

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. []

21.4.1.1 Supported optional parameter for <option list> argument

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

?X wi l l return a s i mi l a ri ty va l ue (between 0 a nd 1.0), here 0.833


If you perform a fuzzy s ea rch wi th the s tri ng metri c Ja ro, e.g. Lucene query text
"good~0.8", thi s wi l l ma tch "food", a s 0.833 i s >= 0.8
Exa mpl e:
?- _queryIndex(modul e1, [s tri ngmetri c("Ja ro")], "na me_en:good~0.8", 0, 10, ?Obj, ?
Tc, ?Sc, ?Order, ?Opt).
Us e s tri ng metri c "Ja ro" for fuzzy s ea rch.

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

21.4.1.2 Extended syntax for <Lucene query text> argument

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)

s tri ngMetri c Stri ng metri c (s ee a bove)

s ort Sort res ul ts , e.g. s ort='i d des c'


Importa nt res tri cti on:
Sorti ng ca n be done on the "s core" of the document, or on
a ny mul ti Va l ued="fa l s e" i ndexed="true" fi el d provi ded
tha t fi el d i s ei ther non-tokeni zed (i e: ha s no Ana l yzer) or
us es a n Ana l yzer tha t onl y produces a s i ngl e Term (i e:
us es the KeywordTokeni zer)
See for more deta i l s :
http://wi ki .a pa che.org/s ol r/CommonQueryPa ra meters

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

21.4.1.3 Available fields for objects in modules


If the ful l text i ndexi ng i s ena bl ed, OntoBroker crea tes i ndex entri es for every ObjectLogi c object whi ch i s us ed
i n the gi ven modul e a s concept, i ns ta nce, a ttri bute or rel a ti on. Thi s mea ns hi ts a re a l wa ys to the i ndexed
ObjectLogi c object, whos e term i s returned i n the <object> pa ra meter.
Si de rema rk
Ful l text i ndexi ng i s ena bl ed by the OntoConfi g.prp pa ra meter, e.g.
FullTextIndex = on
The fi el ds i n the ful l -text i ndex a re defi ned i n the ful l texti ndex-confi g.xml a nd ful l texti ndex-s chema .xml . (s ee
s ecti on “Ful l text i ndexer s etti ngs ” i n the OntoBroker Ma nua l Appendi x for deta i l s ).
As a defa ul t, the fol l owi ng fi el ds a re fi l l ed for every object:

241
OntoBroker 6.3 Appendi x

Field Stored Indexed Description

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)

type yes yes Thi s fi el d conta i ns the types of the object:


i = Ins ta nce
c = Concept
a = Attri bute s peci fi ca ti on
r = Rel a ti on s peci fi ca ti on
p = Property s peci fi ca ti on
u = Rul e
q = Query
t = Cons tra i nt

a s s ertedi s a yes yes For i ns ta nces thi s fi el d conta i ns the i ds of i ts concepts

repr_de yes yes Conta i ns the l a ngua ge-dependent l a bel for a gi ven object
repr_en

docu_de no yes Conta i ns the l a ngua ge-dependent documenta ti on for a gi ven


object
docu_en

s yn_de yes yes Conta i ns l a ngua ge-dependent s ynonyms


s yn_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 .

s yn yes yes Conta i ns a l l s ynonyms for a l l l a ngua ges

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

a l l :ci ty s ea rches i n the fi el d “a l l ” for the word “ci ty”

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 ObjectLogic Built-ins


The des cri pti ons of a l l of the Bui l t-i ns i ncl ude arity, signatures (whi ch i ndi ca te the type of the a rguments ),
bindings (where f mea ns tha t the a rgument mus t be free a nd b tha t i t mus t be bound), pl a i n Engl i s h description,
a nd exam ples. The a bbrevi a ti ons for the va ri ous types menti oned i n the s i gna tures a re des cri bed i n the
fol l owi ng cha pter.

21.4.2.1 Comparisons

Comparison Arity Signatures Bindings Description Examples


== 2 va ri ous bb, bf, fb, ff True i f a rgument ?X==?Y
da ta types 2 ca n be
=
pos s i bl e obta i ned from
a rgument 1 by
va ri a bl e
rena mi ng.

= 2 va ri ous ff, fb, bf, bb Argument 1 ?X=?Y


da ta types uni fi es wi th ?X=5
pos s i bl e a rgument 2.
!=

!= 2 va ri ous ff, fb, bf, bb Argument 1 does ?X!=?Y


da ta types not uni fy wi th
pos s i bl e a rgument 2.

243
OntoBroker 6.3 Appendi x

21.4.2.2 Basic Mathematical Built-ins

Math. Built-in Arity Signatures Bindings Description Example

_mul ti pl y 3 =>(_number, fbb, bfb, bbf Mul ti pl i es the _mul ti pl y(2,3,?X)


_number, numbers i n
_number) a rguments 1 a nd
3. Bi nds the
The a rguments
res ul t to
ca n be a ny
a rgument 3.
number of a
s upported
numeri c da ta
type. Convers i on
rul es a ppl y.

_a dd 3 =>(_number, fbb, bfb, bbf, Adds the _a dd(1,?X,5)


_number, bbb numbers i n
_number) a rguments 1 a nd
2. Bi nds
The a rguments
a rgument 3 to
ca n be a ny
the res ul t.
number of a
s upported
numeri c da ta
type. Convers i on
rul es a ppl y.

_a bs 2 =>(_number, bf, fb, bb Bi nds a rgument _a bs (-1,?X)


_number, 2 to the
_number) a bs ol ute va l ue
of a rgument 1.
The a rguments
ca n be a ny
number of a
s upported
numeri c da ta
type. Convers i on
rul es a ppl y.

21.4.2.3 Basic Mathematical Functions

Thes e a re ba s i c ma thema ti ca l functi ons a re a va i l a bl e i n i s -s ta tements , e.g. ?X i s (?Y+3/?Z+5)*s i n(?Z) whi ch


mea ns tha t the va l ue of the expres s i on on the ri ght i s a s s i gned to va ri a bl e ?X. Note tha t functi ons a re not
prefi xed wi th a n unders core '_'.
mod wi l l jus t be a va i l a bl e for l ong a nd i nt. s i n, cos , ta n, a s i n, a cos , a ta n, exp, pow, l og a nd s qrt wi l l jus t be
a va i l a be for doubl e.

Math. Function Arity Signatures Bindings Description Example


+ 1 _number b Mul ti pl i es +2
a rgument by +1
a nd returns the
res ul t.

- 1 _number b Mul ti pl i es -2
a rgument 1 by -1
a nd returns the
res ul t.

+ 2 (_number, bb Adds the two 3+2


_number), numbers ,

244
OntoBroker 6.3 Appendi x

(_s tri ng,s tri ng), s tri ngs , or


(_da teTi me, da tes /ti mes
_dura ti on,), wi th dura ti on,
( _ti me, a nd returns the
_dura ti on,), res ul t.
(_da te,
_dura ti on)

- 2 (_number, bb Subtra cts the 3-2


_number,), two numbers or
(_da teTi me, da tes /ti mes
_dura ti on,), wi th dura ti on,
(_ti me, a nd returns the
_dura ti on,), res ul t.
(_da te,
_dura ti on)

* 2 _number, bb Mul ti pl i es the 3*2


_number two numbers
gi ven i n
a rguments 1 a nd
2 a nd returns
the res ul t.

/ 2 _number, bb Di vi des the two 3.2 / 1.1


_number numbers gi ven
i n a rguments 1
a nd 2 a nd
returns the
res ul t.

modmo 2 _i nteger, bb Computes the 5 mod 2


_i nteger rema i nder of the
di vi s i on of the
two i ntegers
gi ven i n
a rguments 1 a nd
2 a nd returns
the res ul t.

a bs 1 _number b Returns the a bs (-1)


a bs ol ute va l ue
of the
a rgument.

ma x 2 _number, bb Returns the ma x(1,2)


_number grea ter of the
va l ues of
a rguments 1 a nd
2.

mi n 2 _number, bb Returns the mi n(1,2)


_number s ma l l er of the
va l ues of
a rguments 1 a nd
2.

round 1 _number b Returns the round(2.4)


cl os es t i nteger
to the va l ue of
a rgument 1.

cei l 1 _number b Returns the cei l (2.3)


s ma l l es t _l ong

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.

fl oor 1 _number b Returns the fl oor(2.3)


l a rges t _l ong 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.

ta n 1 _doubl e b Returns the ta n(0.8)


ta ngent of the
va l ue i n
a rgument 1.

a ta n 1 _doubl e b Returns the a ta n(8)


a rcta ngent of
the va l ue i n
a rgument 1.

sin 1 _doubl e b Returns the s i ne s i n(5)


of the va l ue i n
a rgument 1.

asin 1 _doubl e b Returns the a s i n(0.5)


a rcs i ne of the
va l ue i n
a rgument 1.

cos 1 _doubl e b Returns the cos (8)


cos i ne va l ue of
the va l ue i n
a rgument 1.

a cos 1 _doubl e b Returns the a cos (0.8)


a rccos i ne va l ue
of the va l ue i n
a rgument 1.

exp 1 _number b Returns the exp(3)


Eul er's number
ra i s ed to the
power of the
va l ue gi ven i n
a rgument 1.

s qrt 1 _number b Returns the exp(3)

246
OntoBroker 6.3 Appendi x

pos i ti ve s qua re
root of a
pos i ti ve
number.

l og 1 _number, b Returns na tura l l og(1)


_number the l oga ri thm of
the va l ue i n
a rgument 1.

pow 3 _number, bb Ra i s es a rgument pow(2,3)


_number 1 to the power
gi ven i n
a rgument 2.

from the copyright of the web page http://forum.projects.semwebcentral.org/forum-syntax.html

21.4.3 General Syntactic Changes


In the yea rs s i nce the publ i ca ti on of the ori gi na l pa per on F-l ogi c i n 1995, new i dea s ha ve been propos ed a nd
a number of s ys tems ba s ed on F-l ogi c ha ve been devel oped. Thi s forum a ttempts to orga ni ze thes e i dea s a nd
propos e a uni fyi ng s ynta x a nd s ema nti cs tha t i ncorpora tes the bes t i dea s . It i s expected tha t the va ri ous
s ys tems , s uch a s FLORA-2 a nd OntoBroker, a nd the rel a ted s peci fi ca ti ons , s uch a s WSML a nd SWSL, wi l l be
l a rgel y compa ti bl e wi th thi s s ynta x.

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.

Cardinality constraints on attributes and methods


Synta x:
a[foo {2:3} => type].
The s ymbol * i n the upper bound pa rt i s us ed for i nfi ni ty. The cons tra i nt {0:1} enforces the functi ona l property
a nd hence functi ona l methods ca n be expres s ed us i ng thi s type of cons tra i nts .

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.

Variables, quantification, and Lloyd-Topor extensions


a) Al l va ri a bl es a re denoted a s ?Va r

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.

Rule labels and other metadata


Every rul e a nd query ca n be preceded by a meta da ta a nnota ti on of the form
@{metaannotation} rule/query/constraint

The a nnota ti on ha s the form:


metaannotation ::= '@{' id | frames | id ',' frames '}'
frames ::= frame (',' frame)*)?

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

Opti on Des cri pti on

sort(asc(?X),desc(?Y),...) Sort the output of the query i n the a s cendi ng order of


bi ndi ngs for ?X, des cendi ng order of bi ndi ngs for ?Y,
etc. The a s c(...) s peci fi ca ti on i s i mpl i ed a nd ca n be
l eft out. For i ns ta nce, s ort(?X,des c(?Y),...) i s the s a me
a s s ort(a s c(?X),des c(?Y),...).

instance, sort(?X,desc(?Y),...) is the The output to the query s houl d be a s et of tupl es (?


same as sort(asc(?X),desc(?Y),...). Y,?X), i .e., the bi ndi ngs for ?Y go fi rs t.

maxanswers(NUMBER) Speci fi es tha t onl y (a t mos t) the fi rs t NUMBER of


a ns wers needs to be computed.

maxtime(NUMBER) Stop the computa ti on a fter thi s NUMBER of s econds .

Exa mpl es :
@{rule12}
bar :- foo.

@{rule15,rule15[author->Bob, date-> "1979-09-13T17:31:41-02:30"^^_dateTime]}


foo :- bar.

@{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

Methods with arguments, HiLog syntax


The ori gi na l F-l ogi c us ed the @-s ynta x to s epa ra te the method na me from the method a rguments (e.g., o[m@
(a ,b)->v]). The purpos e of thi s s epa ra ti on wa s to a l l ow va ri a bl es over the method na mes . In thi s forum i t wa s
deci ded to a ba ndon the @-s ynta x a nd us e the Hi Log s ynta x i ns tea d.

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

Builtin predicates and functions


Thes e a re des cri bed i n deta i l i n a s epa ra te document 243 .

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.

Name space prefixes and related issues.


To s i mpl i fy the job of wri ti ng IRIs , RDF ha s propos ed a s ynta x of the form prefi x:l oca l Pa rt, whi ch wa s a dopted
from the s ynta x of QNa mes (qua l i fi ed na mes ) i n XML. Unfortuna tel y, the mea ni ng of s uch a cons truct i n RDF i s
di fferent from i ts mea ni ng i n XML a nd the i s s ue i s further confus ed by the fa ct tha t RDF a l s o ca l l s thei r
cons truct a QNna me. In RDF, prefi x i s a ma cro tha t expa nds to a IRI a nd prefi x:l oca l Pa rt denotes a IRI tha t i s
cons tructed by conca tena ti ng the ma cro-expa ns i on of prefi x wi th l oca l Pa rt. In XML, prefi x:l oca l Pa rt does not
denote a IRI. Ins tea d, i t i s a pa i r of the form (ma cro-expa ns i on of prefi x, l oca l Pa rt). To a voi d thi s confus i on,
we wi l l ca l l the RDF cons truct a n s QNa me (s eri a l i zed QNa me) a nd us e the s ynta x prefi x#l oca l Pa rt.
Prefi xes ca n be decl a red a s fol l ows :
:- prefix prefix-name = "IRI".
The s ynta x for ful l IRIs i s des cri bed i n the Da ta Types 250 document.
We wi l l a l s o s upport defa ul t IRI prefi xes wi th the s ta tements of the form
:- default prefix "IRI".
The defa ul t prefi x a ffects IRI s peci fi ed a s l oca l Na me (wi thout the prefi x na me).

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

21.4.4 Data Types


Pri mi ti ve da ta types a re repres ented by cons ta nts of s peci a l form: _da ta typeNa me"l i tera l ". The unders core _
a nd the quotes a re pa rt of the s ynta x. da ta typeNa me i s the na me of the da ta type a nd l i tera l i s the va l ue-pa rt
of the cons ta nt. The da ta type na mes a nd thei r a ttri butes a re l i s ted bel ow. The s upported da ta types cl os el y
corres pond to XML Schema da ta types .
Note tha t the form of the da ta type cons ta nts ma kes no a s s umpti on a bout the a ctua l i nterna l repres enta ti on
of thes e cons ta nts . A va ri ety of opti ons i s pos s i bl e. The compi l er ca n tra ns l a te s uch cons ta nts to functi on
terms or to externa l ca l l s to Ja va or C progra ms . For i ns ta nce, a cons ta nt of the ti me da ta type s uch a s
"12:33:44"^^_ti me ca n be compi l ed i nto a term l i ke $#%&ti me(12,33,44) or i nto $#%&ti me(12,33,44,45224) (45224
i s the number of s econds i n the ti me l i tera l a nd ca n be us ed for compa ri s on wi th other l i tera l s ) or i nto
Ti me#@!([49,50,51,51,52,52]) (here the numbers i n the l i s t a re the ASCII codes of the di gi ts i n the da te).
We a l s o defi ne s ynta x for va ri a bl es tha t ca n be bound onl y to cons ta nts of the corres pondi ng da ta types . The
s ynta x i s ?va ri a bl eNa me^^da ta typeNa me, where ^^ a nd ? a re pa rt of the s ynta x, whi l e da ta typeNa me i s the
na me of a da ta type. For i ns ta nce, ?Y^^_ti me.
Some da ta types , l i ke ti me, da teTi me, etc., a re exa ct a na l ogues of the corres pondi ng XML Schema types . In
thi s ca s e, thei r na mes wi l l be denoted us i ng s tri ngs tha t ha ve the form of a IRI. For i ns ta nce, 'http://www.w3.
org/2001/XMLSchema #ti me'. However, for conveni ence, a l l type na mes wi l l ha ve one or more F-l ogi c s peci fi c
a bbrevi a ted forms , s uch a s _ti me or _t. Thes e a bbrevi a ted forms a re ca s e-i ns ens i ti ve. So, _ti me a nd _Ti Me
a re a s s umed to be equi va l ent. In a ddi ti on, when the type na mes ha ve the form of a n IRI, the compa ct prefi x
repres enta ti on i s s upported. For i ns ta nce, i f xs d i s a prefi x na me for 'http://www.w3.org/2001/XMLSchema #'
then "12:33:55"^^<http://www.w3.org/2001/XMLSchema #ti me> ca n be wri tten a s "12:33:55"^^xs d#ti me'.
The methods tha t a re a ppl i ca bl e to ea ch pa rti cul a r pri mi ti ve type va ry from type to type. However, certa i n
methods a re more or l es s common:
_toString, whi ch a ppl i es to a da ta type cons ta nt a nd returns i ts pri nta bl e repres enta ti on. For i ns ta nce,
i f ?Y i s bound to "12:44:23"^^_ti me then ?Y[_toStri ng->'12:44:23'] wi l l be true.
_toType( parameters ), whi ch a ppl i es to the a ny cl a s s corres pondi ng to a pri mi ti ve da ta type (for
i ns ta nce, _ti me). Mos t types wi l l ha ve two vers i ons of thi s method. One wi l l a ppl y to a rguments tha t
repres ent the components of a da ta type. For i ns ta nce, _ti me[_toType(12,23,45)->"12:23:45"^^_ti me]. The
other wi l l a ppl y to the s tri ng repres enta ti on of the da ta type. For i ns ta nce, _ti me[_toType('12:23:45')-
>"12:23:45"^^_ti me].
_isTypeOf( constant ), whi ch a ppl i es to every da ta type cl a s s (e.g., _ti me) a nd determi nes whether
cons ta nt ha s the gi ven pri mi ti ve type (_ti me i n thi s exa mpl e).
_equal( constant ), whi ch tel l s when the gi ven da ta type cons ta nt equa l s s ome other term.
_lessThan( constant ), whi ch tel l s when one cons ta nt i s l es s tha n s ome other terms . For i ntegers ,
fl oa ts , ti me, da tes , dura ti ons , a nd s tri ngs , thi s method corres ponds to the na tura l order on thes e types .
For other types thi s method returns fa l s e.
_typeName, whi ch tel l s the type na me (a nd thus a l s o cl a s s ) of the gi ven da ta type.

250
OntoBroker 6.3 Appendi x

21.4.4.1 Supported Data Types

_dateTime

Expl a na ti on XML Schema da teTi me type

Norma l form "ZYYYY-MM-DDTHH:MM:SS.s ZHH:MM"^^_da teTi me.


The s ymbol s -, :, T, a nd . a re pa rt of the s ynta x. The l eftmos t Z i s opti ona l s i gn (-). The
pa rt tha t s ta rts wi th the s econd Z i s opti ona l a nd repres ents the ti me zone (the s econd
Z i s a s i gn, whi ch ca n be ei ther + or -; note tha t the fi rs t Z ca n be onl y the mi nus s i gn or
nothi ng). The pa rt tha t s ta rts wi th T i s a l s o opti ona l ; i t repres ents the ti me of the
s peci fi ed da y. The pa rt of the ti me component of the form .s repres ents fra cti ons of the
s econd. Here s ca n be a ny pos i ti ve i nteger.

Cl a s s _da teTi me

Synonyms _dt, <http://www.w3.org/2001/XMLSchema #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

Component _da teTi me[_da teSi gn *=> _i nteger]


methods _da teTi me[_yea r *=> _i nteger]
_da teTi me[_month *=> _i nteger]
_da teTi me[_da y *=> _i nteger]
_da teTi me[_hour *=> _i nteger]
_da teTi me[_mi nute *=> _i nteger]
_da teTi me[_s econd *=> _i nteger]
_da teTi me[_zoneSi gn *=> _i nteger]
_da teTi me[_zoneHour *=> _i nteger]
_da teTi me[_zoneMi nute *=> _i nteger]

Other methods _da teTi me[_toStri ng *=> _s tri ng]


_da teTi me[*=> _equa l s (_object)]
_da teTi me[*=> _l es s Tha n(_object)]
_da teTi me[_typeNa me *=> _s tri ng]
_da teTi me[_a dd(_dura ti on) *=> _da teTi me]

Exa mpl es "2001-11-23T12:33:55.123-02:30"^^_da teTi me


"2001-11-23T12:33:55.123-02:30"^^<http://www.w3.org/2001/XMLSchema #da teTi me>
"-0237-11-23T12:33:55"^^_da teTi me
Note tha t thi s da te refers to yea r 238 BCE.
"2001-11-23T10:00:00Z"^^_da teTi me[_da y -> 23]
"2001-11-23T10:00:00Z"^^_da teTi me.[_toStri ng -> '2001-11-23T00:00:00+00:00']
"2001-11-23T18:33:44-02:30"^^_da teTi me[_a dd("-P22Y2M10DT1H2M3S"^^_dura ti on) ->
"1979-09-13T17:31:41-02:30"^^_da teTi me].

251
OntoBroker 6.3 Appendi x

_date
Expl a na ti on XML Schema da te type

Norma l form "ZYYYY-MM-DDSHH:MM"^^_da te.


The s ymbol s - a nd : a re pa rt of the s ynta x. The s ymbol S repres ents the ti mezone s i gn (+
or -). The ti mezone pa rt (begi nni ng wi th S) i s opti ona l . The l eftmos t Z i s opti ona l s i gn
(-). Note tha t unl i ke _da teTi me, whi ch repres ents a s i ngl e ti me poi nt, _da te repres ents
dura ti on of a s i ngl e da y.

Cl a s s _da te

Synonyms _d, <http://www.w3.org/2001/XMLSchema #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

Component _da te[_da teSi gn *=> _i nteger]


methods _da te[_yea r *=> _i nteger]
_da te[_month *=> _i nteger]
_da te[_da y *=> _i nteger]
_da te[_zoneSi gn *=> _i nteger]
_da te[_zoneHour *=> _i nteger]
_da te[_zoneMi nute *=> _i nteger]

Other methods _da te[_toStri ng *=> _s tri ng]


_da te[*=> _equa l s (_object)]
_da te[*=> _l es s Tha n(_object)]
_da te[_typeNa me *=> _s tri ng]
_da te[_a dd(_dura ti on) *=> _da te]

Exa mpl es "2001-11-23-02:30"^^_da te


"2001-11-23"^^_da te,
"-0237-11-23"^^_da te
Note tha t thi s da te refers to yea r 238 BCE.
"2001-11-23"^^_da te[_da y -> 23]
"2001-11-23"^^_da te[_toStri ng -> '2001-11-23+00:00']
"2001-11-23-02:30"^^_da te[_a dd("-P2Y2M10DT1H2M"^^_dura ti on) -> "1979-09-13-
03:32"^^_da teTi me]

252
OntoBroker 6.3 Appendi x

_time
Expl a na ti on XML Schema ti me da ta type

Norma l form "HH:MM:SS.s ZHH:MM"^^_ti me


The s ymbol s : a nd . a re pa rt of the s ynta x. The pa rt .s i s opti ona l . It repres ents fra cti ons
of a s econd. Here s ca n be a ny pos i ti ve i nteger. The s i gn Z repres ents the s i gn of the
ti mezone (+ or -). The fol l owi ng HH repres ents ti me zone hours a nd MM ti me zone
mi nutes . The ti me zone pa rt i s opti ona l .

Cl a s s _ti me

Synonyms _t, <http://www.w3.org/2001/XMLSchema #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

Component _ti me[_hour *=> _i nteger]


methods _ti me[_mi nute *=> _i nteger]
_ti me[_s econd *=> _i nteger]
_ti me[_zoneSi gn *=> _i nteger]
_ti me[_zoneHour *=> _i nteger]
_ti me[_zoneMi nute *=> _i nteger]

Other methods _ti me[_toStri ng *=> _s tri ng]


_ti me[*=> _equa l s (_object)]
_ti me[*=> _l es s Tha n(_object)]
_ti me[_typeNa me *=> _s tri ng]
_ti me[_a dd(_dura ti on) *=> _ti me]

Exa mpl es "11:24:22"^^_ti me


"11:24:22"^^<http://www.w3.org/2001/XMLSchema #ti me>
_ti me[_toType(12,44,55) -> "12:44:55"^^_ti me]
"12:44:55"^^_ti me[_mi nute -> 44]
"12:44:55"^^_ti me[_toStri ng -> '12:44:55']
"12:44:55"^^_ti me[_a dd("P2M3S"^^_dura ti on) -> "12:46:58"^^_ti me]

253
OntoBroker 6.3 Appendi x

_duration
Expl a na ti on XML Schema dura ti on type

Norma l form "s PnYnMnDTnHnMnS"^^_dura ti on


Here s i s opti ona l s i gn (-), P i ndi ca tes tha t thi s i s a dura ti on type, a nd Y, M, D, H, M, S
denote yea r, month, da te, hour, mi nutes , a nd s econds . T s epa ra tes da te from ti me. The
s ymbol n s ta nds for a ny pos i ti ve number (for i ns ta nce, the number of hours ca n be
more tha n 12 a nd the number of mi nutes a nd s econds ca n be more tha n 60. The pa rt
tha t s ta rts wi th T i s opti ona l a nd s ome of the el ements i n the da te a nd the ti me pa rts
ca n be omi tted.

Cl a s s _dura ti on

Synonyms <http://www.w3.org/2001/XMLSchema #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

Component _dura ti on[_yea rs *=> _i nteger]


methods _dura ti on[_months *=> _i nteger]
_dura ti on[_da ys *=> _i nteger]
_dura ti on[_hours *=> _i nteger]
_dura ti on[_mi nutes *=> _i nteger]
_dura ti on[_s econds *=> _i nteger]

Other methods _dura ti on[_toStri ng *=> _s tri ng]


_dura ti on[*=> _equa l s (_object)]
_dura ti on[*=> _l es s Tha n(_object)]
_dura ti on[_typeNa me *=> _s tri ng]
_dura ti on[_a dd(_dura ti on) *=> _dura ti on]

Exa mpl es "P5Y5M10DT11H24M22S"^^_dura ti on


"-P2Y05M10DT11H24M22"^^_dura ti on[_mi nutes -> 24]

254
OntoBroker 6.3 Appendi x

_boolean
Expl a na ti on XML Schema Bool ea n type

Norma l form "true"^^_bool ea n, "fa l s e"^^_bool ea n


or s horter forms : _true, _fa l s e

Cl a s s _bool ea n

Synonyms <http://www.w3.org/2001/XMLSchema #bool ea n>

Cl a s s methods _bool ea n[_toStri ng => _s tri ng]


_bool ea n[=> _i s TypeOf(_object)]

Other methods _bool ea n[_toStri ng *=> _s tri ng]


_bool ea n[*=> _equa l s (_object)]
_bool ea n[*=> _l es s Tha n(_object)]

Note:
_fa l s e[_l es s Tha n(_true)])
_bool ea n[_typeNa me *=> _s tri ng]

Exa mpl es "true"^^_Bool , _true, _fa l s e

_double
Expl a na ti on XML Schema doubl e type

Norma l form "va l ue"^^_doubl e


where va l ue i s a fl oa ti ng poi nt number of doubl e l ength tha t us es the regul a r deci ma l
poi nt repres enta ti on wi th a n opti ona l exponent.
Short forms : s a me repres enta ti on wi thout "..."^^_doubl e wra pper.

Cl a s s _doubl e

Synonyms <http://www.w3.org/2001/XMLSchema #doubl e>

Cl a s s methods _doubl e[_toType(_deci ma l ) => _doubl e] Converts deci ma l s to doubl es . Error, i f


overfl ow.
_doubl e[_toType(_l ong) => _doubl e] Converts l ong i ntegers to doubl es .
_doubl e[=> _i s TypeOf(_object)]

Other methods _doubl e[_fl oor *=> _i nteger]


_doubl e[_cei l i ng *=> _i nteger]
_doubl e[_round *=> _i nteger]
_doubl e[_toStri ng *=> _s tri ng]
_doubl e[*=> _equa l s (_object)]
_doubl e[*=> _l es s Tha n(_object)]
_doubl e[_typeNa me *=> _s tri ng]

Exa mpl es "2.50"^^_doubl e, 2.50, 25E-1

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)

Norma l form "va l ue"^^_deci ma l


where va l ue i s a number tha t us es the regul a r deci ma l poi nt repres enta ti on. Thi s type
i s a s upertype of _i nteger.

Cl a s s _deci ma l

Synonyms <http://www.w3.org/2001/XMLSchema #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)]

Other methods _deci ma l [_fl oor *=> _i nteger]


_deci ma l [_cei l i ng *=> _i nteger]
_deci ma l [_round *=> _i nteger]
_deci ma l [_toStri ng *=> _s tri ng]
_deci ma l [*=> _equa l s (_object)]
_deci ma l [*=> _l es s Tha n(_object)]
_deci ma l [_toStri ng *=> _s tri ng]
_deci ma l [_typeNa me *=> _s tri ng]

Exa mpl es "2.50"^^_deci ma l , "12"^^<http://www.w3.org/2001/XMLSchema #deci ma l >

_integer
Expl a na ti on XML Schema i ntegers (a rbi tra ry l ength)

Norma l form "va l ue"^^_i nteger


where va l ue i s a n i nteger i n i ts regul a r repres enta ti on i n the deci ma l s ys tem.
_i nteger i s a s ubtype of _deci ma l . For i ns ta nce, "12"^^_i nteger = "12"^^_deci ma l =
"12.0"^^_deci ma l , etc.

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

Synonyms _i nt, <http://www.w3.org/2001/XMLSchema #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

Other methods _i nteger[_toStri ng *=> _s tri ng] _i nteger[*=> _equa l s (_object)]


_i nteger[*=> _l es s Tha n(_object)]
_i nteger[_typeNa me *=> _s tri ng]

Exa mpl es "55"^^_i nteger, "55"^^_i nt

256
OntoBroker 6.3 Appendi x

_long
Expl a na ti on XML Schema l ong i ntegers

Norma l form "va l ue"^^_l ong


where va l ue i s a n i nteger i n i ts regul a r repres enta ti on i n the deci ma l s ys tem. A s horter
form wi thout the "..."^^_l ong wra pper i s a l s o a l l owed.
Note tha t a l though XML s chema pres cri bes tha t _l ong mus t be a s ubtype of _i nteger, 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 _l ong

Synonyms <http://www.w3.org/2001/XMLSchema #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

Other methods _l ong[_toStri ng *=> _s tri ng] _l ong[*=> _equa l s (_object)]


_l ong[*=> _l es s Tha n(_object)]
_l ong[_typeNa me *=> _s tri ng]

Exa mpl es 123, 55, "55"^^_l ong

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]

Norma l form "s tri ng IRI repres enta ti on"^^_i ri

Cl a s s _i ri

Synonyms <http://www.w3.org/2007/ri f#i ri >


<http://www.w3.org/2007/ri f#uri >
_"s tri ng IRI repres enta ti on". For i ns ta nce, "http://foo.ba r.com/moo"^^_i ri ca n be wri tten
a s _"http://foo.ba r.com/moo".

Cl a s s methods _i ri [_toType(_s tri ng) => _i ri ]


_i ri [=> _i s TypeOf(_object)]

Component _i ri [_s cheme *=> _s tri ng]


methods _i ri [_us er *=> _s tri ng]
_i ri [_hos t *=> _s tri ng]
_i ri [_port *=> _s tri ng]
_i ri [_pa th *=> _s tri ng]
_i ri [_query *=> _s tri ng]
_i ri [_fra gment *=> _s tri ng]

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.

Other methods _i ri [_toStri ng *=> _s tri ng]


_i ri [*=> _equa l s (_object)]
_i ri [_typeNa me *=> _s tri ng]

Exa mpl es _"http://foo.ba r.com/a bc"


"http://foo.ba r.com/a bc"^^_i ri
_i ri [_toType('http://foo.ba r.com/a bc') -> "http://foo.ba r.com/a bc"^^_i ri ]
_"http://foo.ba r.com/a bc"[_hos t -> 'foo.ba r.com']

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

Norma l form "va l ue"^^_s tri ng


A s horter form 'va l ue' i s a l s o a l l owed.
Si ngl e-quoted s equence of cha ra cters . Al pha numeri c s tri ngs tha t s ta rt wi th a l etter do
not need to be quoted. In the ful l repres enta ti on (wi th the "..."^^_s tri ng wra pper), the
doubl e quote s ymbol a nd the ba cks l a s h mus t be es ca ped wi th a ba cks l a s h. In s hort
repres enta ti on, the s i ngl e quote s ymbol a nd the ba cks l a s h mus t be es ca ped wi th a
ba cks l a s h.

258
OntoBroker 6.3 Appendi x

Cl a s s _s tri ng

Synonyms http://www.w3.org/2001/XMLSchema #s tri ng

Cl a s s methods _s tri ng[=> _i s TypeOf(_object)]

Other methods _s tri ng[*=> _equa l s (_object)]. Bi ndi ng: bb.


_s tri ng[*=> _l es s Tha n(_object)]. Bi ndi ng: bb.
_s tri ng[_typeNa me *=> _s tri ng]. Bi ndi ngs : bf, bb.
_s tri ng[*=> _conta i ns (_s tri ng)]. Bi ndi ng: bb.
_s tri ng[_conca t(_s tri ng) *=> _s tri ng]. Bi ndi ngs : fbb, bfb, bbf, bbb
_s tri ng[_cut(_i nteger) *=> _s tri ng]. Bi ndi ngs : bbf, bbb. Returns a s ubs tri ng of the
s tri ng-object trunca ted by the number of cha ra cters s peci fi ed i n the method
a rgument. Trunca ti on ta kes pl a ce on the ri ght.
_s tri ng[_fi l l (_s tri ng) *=> _s tri ng]. Bi ndi ngs : bbbf, bbbb. Fi l l s the object-s tri ng wi th a
l etter from the fi rs t method a rgument up to the l ength s peci fi ed i n the s econd
method a rgument. For i ns ta nce, a bc[_fi l l (D,7) -> a bcDDDD].
_s tri ng[_ma tch(_s tri ng) *=> _l i s t]. Bi ndi ngs : bbf, bbb. The res ul t of the method i s a
l i s t of terms of the form ma tch(ma tchi ngPos i ti on,ma tchi ngSubs tri ng), whi ch
repres ents ma tches i ns i de the object-s tri ng. The ma tch i s done a ga i ns t a Perl regul a r
expres s i on gi ven a s the method a rgument. The l i s t i s s orted i n the a s cendi ng order
of pos i ti ons of the ma tches . The counti ng of pos i ti ons i n the object s tri ng s ta rts wi th
0.
_s tri ng[_i ndexOf(_s tri ng) *=> _i nt]. Bi ndi ngs : bbf, bbb. The res ul t of thi s method i s a
l i s t of pos i ti ons a t whi ch the s tri ng gi ven a s a rgument to the method ma tches wi thi n
the object s tri ng. The pos i ti ons i n the l i s t a re ordered i n the a s cendi ng order.
_s tri ng[_l a s tIndexOf(_s tri ng) *=> _i nt]. Bi ndi ngs : bbf, bbb. The res ul t of thi s method
i s a l i s t of pos i ti ons a t whi ch the s tri ng gi ven a s a rgument to the method ma tches
wi thi n the object s tri ng. The pos i ti ons i n the l i s t a re ordered i n the des cendi ng
order.For thi s beha vi our, us e _i ndexOf together wi th revers e. Thi s i mpl ementa ti on
del i vers jus t the l a s t pos i ti on.
_s tri ng[_fi rs tIndexOf(_s tri ng) *=> _i nt]. Bi ndi ngs : bbf, bbb. Thi s method i s a dded from
us . It del i vers jus t the fi rs t pos i ti on.
_s tri ng[_repl a ce(_s tri ng,_s tri ng) *=> _s tri ng]. Bi ndi ng: bbbf, bbbb. Repl a ces every
occurrence of the Perl regul a r expres s i on i ns i de the object s tri ng wi th the s tri ng gi ven
i n the s econd a rgument of the method. The Perl regul a r expres s i on i s gi ven i n the
fi rs t a rgument.
_s tri ng[_s pl i t(_s tri ng) *=> [_s tri ng,_s tri ng]]. Bi ndi ng: bbf, bbb. Spl i ts the object-s tri ng
by the regul a r expres s i on gi ven i n the method a rgument. The s pl i t occurs a t the fi rs t
cha ra cter of the fi rs t ma tch. The res ul t i s a l i s t of two s tri ngs obta i ned by the s pl i t.
For i ns ta nce, Eddi e[_s pl i t(d) -> [E,ddi e]].
_s tri ng[_revers e *=> _s tri ng]. Bi ndi ngs : bf, fb, bb.
_s tri ng[_l ength *=> _i nteger]. Bi ndi ng: bf, bb.
_s tri ng[_tokeni ze(_s tri ng) *=> _l i s t]. Bi ndi ngs : bbf, bbb. Brea ks the object-s tri ng i nto
a l i s t of tokens a t every occurrence of a ny del i mi ter 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]].
_s tri ng[_toUpper *=> _s tri ng]. Bi ndi ngs : bf, bb. The va l ue of the method i s the object
s tri ng wi th a l l cha ra cters converted to the upper ca s e.
_s tri ng[_toLower *=> _s tri ng]. Bi ndi ngs : bf, bb. The va l ue of the method i s the object
s tri ng wi th a l l cha ra cters converted to the l ower ca s e.
_s tri ng[_cha rAt(_i nteger) *=> _s tri ng]. Bi ndi ngs : bbf, bbb. The va l ue of the method i s
the cha ra cter tha t occurs i n the object s tri ng a t the pos i ti on gi ven by the a rgument to

259
OntoBroker 6.3 Appendi x

the method. Pos i ti ons s ta rt wi th 0.


_s tri ng[_di ffAt(_s tri ng) *=> _number_i nteger]. Bi ndi ngs : bbf, bbb. The res ul t of the
method i s the fi rs t pos i ti on where the object s tri ng a nd the method a rgument di ffer.
Pos i ti ons s ta rt wi th 0. The the truth va l ue i s fa l s e i f the two s tri ngs a re equa l .
_s tri ng[*=> _s ta rts Wi th(_s tri ng)]. Bi ndi ng: bb.
_s tri ng[*=> _ends Wi th(_s tri ng)]. Bi ndi ng: bb.
_s tri ng[_s ubs tri ng(_i nteger,_i nteger) *=> _s tri ng]. Bi ndi ng: bbbf.a nd: bbbb Returns a
s ubs tri ng of the object s tri ng, where the s ta rti ng a nd the endi ng pos i ti on of the
s ubs tri ng a re gi ven by the a rguments of the method. -1 i n a rgument 2 mea ns the end
of the s tri ng.
_s tri ng[_tri m(_s tri ng) *=> _s tri ng]. Bi ndi ngs : bbf, bbb. Del etes from the object s tri ng
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. For
i ns ta nce, ' .a b c,\n'[_tri m('\n\r .,') -> 'a b c'].
_s tri ng[_overl a ppedBy(_s tri ng) *=> _i nteger]. Bi ndi ngs : bbf, bbb. True i f a s uffi x of the
object s tri ng i s a l s o a prefi x of the s tri ng gi ven i n the method's a rgument. The res ul t
of the method i s the number of cha ra cters i n the ma xi ma l overl a p.

Exa mpl es "a bc"^^_s tri ng


'a bc'
"a s tri ng\n"^^_Stri ng
'a s tri ng\n'
'a \ts tri ng\b'
's tri ng wi th a \'quoted\' s ubs tri ng'

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

Norma l form "va l ue@l a ngua ge"^^_text


Es ca pi ng conventi ons a re the s a me a s for _s tri ng.

Cl a s s _text

Synonyms http://www.w3.org/2007/ri f#text

Cl a s s methods See _s tri ng

Other methods See _s tri ng.


_text[_l a ngua ge *=> _s tri ng]. Bi ndi ng bf, bb. Get the l a ngua ge of the s tri ng.
_text[_textVa l ue *=> _s tri ng]. Bi ndi ng: bf, bb. Gets the text wi thout the l a ngua ge ta g.

Exa mpl es "a bc@en"^^_text


"a s tri ng\n@en"^^_Text

260
OntoBroker 6.3 Appendi x

_list
Expl a na ti on The Prol og type of l i s t.

Norma l form [el t1, ..., el tn], [el t1,...,el tn|Li s t]


Thi s i s the us ua l type for l i s t terms .

Cl a s s _l i s t

Cl a s s methods _l i s t[=> _i s TypeOf(_object)]


_l i s t[_toType(_object,_l i s t) => _l i s t]
Thi s method i s here for compl etel es s onl y. It defi ned s i mpl y a s _l i s t[_toType(obj,l i s t)
=> [obj|l i s t], for a l l objects obj a nd l i s ts l i s t.

Other methods _l i s t[_toStri ng *=> _s tri ng]


_l i s t[*=> _l es s Tha n(_object)]
_l i s t[*=> _equa l s (_object)]. Bi ndi ng: bb.
_l i s t[_typeNa me *=> _s tri ng]
_l i s t[*=> _conta i ns (_l i s t)]. Bi ndi ng: bb. Tel l s i f a l i s t object conta i ns the method's
a rgument a s a s ubl i s t.
_l i s t[*=> _member(_object)]. Bi ndi ng: bb. The method's a rgument a nd the l i s t-object
ma y not be ful l y ground. In thi s ca s e, the method s ucceeds , i f the a rgument to the
method uni fi es wi th a member of the l i s t.
_l i s t[_a ppend(_l i s t) *=> _l i s t]. Bi ndi ngs : fbb, bfb, bbf, bbb
_l i s t[_i ndexOf(_object) *=> _l ong]. Bi ndi ngs : bbf, bbb. The res ul t of thi s method i s the
fi rs t pos i ti on a t whi ch the a rgument-object uni fi es wi th the l i s t-object.
_l i s t[_l ength *=> _l ong]. Bi ndi ng: bbbf, bbbb. Computes the l ength of the l i s t.
_l i s t[_revers e *=> _l i s t]. Bi ndi ngs : bf, fb, bb.
_l i s t[_s ort *=> _l i s t].
_l i s t[_memberAt(_i nteger) *=> _object]. Bi ndi ngs : bbf, bbb. The va l ue of the method
i s the object tha t occurs i n the l i s t object a t the pos i ti on gi ven by the a rgument to the
method. Pos i ti ons s ta rt wi th 0.
_l i s t[*=> _s ta rts Wi th(_l i s t)]. Bi ndi ng: bb.
_l i s t[*=> _ends Wi th(_l i s t)]. Bi ndi ng: bb.
_l i s t[ *=> _s ubs et(_l i s t)]. Bi ndi ng: bb. True i f the l i s t object conta i ns the a rgument
l i s t.
_l i s t[_overl a ppedBy(_l i s t) *=> _i nteger]. Bi ndi ngs : bbf, bbb. True i f a s uffi x of the l i s t
object i s a l s o a prefi x of the l i s t gi ven i n the method's a rgument. The res ul t of the
method i s the number of cha ra cters i n the ma xi ma l overl a p.

Exa mpl es [a ,b,c]


[a ,b|?X]
[a ,b,c|[d,e]]

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.

Norma l form "s ome fra gment of XML"^^_XMLLi tera l

Cl a s s _XMLLi tera l

Synonyms http://www.w3.org/1999/02/22-rdf-s ynta x-ns #XMLLi tera l

Cl a s s methods See _s tri ng

Component
methods

Other methods See _s tri ng.


Shoul d a dd a pa th expres s i on method.

Exa mpl es "<foo>ba r</foo>"^^_XMLLi tera l

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;
}

A web s ervi ce ca l l from ObjectLogi c coul d l ook l i ke thi s :


?- _callWebservice("http://bundesbank/services/BLZService",
"getDetails", [blz->"66010075"],?Result).

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"]

Ma ppi ng between XML a nd ObjectLogi c


Us i ng both ma ps a nd l i s ts , i t woul d become pos s i bl e to ma p XML di rectl y i nto a n ObjectLogi c cons ta nt term
wi thout l oos i ng the hi era rchi ca l s tructure a nd s equence order. Thi s woul d be very s i mi l a r to the ma ppi ng
between XML a nd JSON.

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"]
]
]
]

Opti ons pa ra meter for bui l t-i ns


Exa mpl e:
?- _queryIndex(module,[return(type),return(title),includeAll,stringMetric("Jaro")],
"searchString",0,10,?OBJ,?TC,?SCORE,?ORDER,?OPT) .

Us i ng the ma p da ta type thi s becomes more rea da bl e to


?- _queryIndex(module,
[return->{type,title},includeAll->true,stringMetric-> "Jaro")],
"searchString",0,10,?OBJ,?TC,?SCORE,?ORDER,?OPT).

Res ul t pa ra meter for bui l t-i ns wi th va ri a bl e content s tructure


Someti me bui l t-i ns need to return va ri a bl e res ul t s ets dependi ng on the opti ons . Thi s ha s a l rea dy been
needed i n the a bove web s ervi ce exa mpl e. Another exa mpl e i s here a l s o the _queryIndex/10 bui l t-i n, where
the ?OPT va ri a bl e returns va ri a bl e a l i s t of functi ons , whi ch i s ha rd to pa s s di rectl y i n ObjectLogi c.

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

ObjectLogic syntax Description


?X=[] Empty l i s t (s peci a l cons ta nt)

?X=[->] Empty ma p (s peci a l cons ta nt)

?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

?X=[a ->{1,2,3},b->[1,2]] Mul ti -va l ued ma p. Note the di fference


equi va l ent to between the va l ues for a a nd b.
?X=[a ->1,a ->2,a ->3,b->[1,2]] a i s mul ti -va l ued, but b ha s a l i s t a s va l ue.

?X = [1,a ->b] // i nva l i d Mi xi ng of l i s t terms a nd key va l ue pa i rs i s


not a l l owed. ObjectLogi c compi l er mus t
throw excepti on

Facts

ObjectLogic syntax Description

p([a ->1,b->2]). Predi ca te p/1 wi th a ma p term a s fi rs t


a rgument

Rules , Queries, Built-ins

ObjectLogic syntax Description


p([?X->?Y]) :- r(?X,?Y). ma p i n rul e hea d

p(?Z) :- ?Z = [?X->?Y], r(?X,?Y). s a me a s a bove

?- ?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][_memberAt(?X)->?Y]. Extended bui l t-i n _memberAt/3 to extra ct


keys a nd/or va l ues from a ma p
returns :
?X = a , ?Y = 1
?X = a , ?Y = 2
?X = b, ?Y = 3

?- [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]

?- [b->1,a ->4,a ->2][_norma l i ze->?X]. Bui l t-i n _norma l i ze/2 to bri ng ma p i n


i nterna l order

returns :
?X = [a ->{2,4}, b->1]

?- _ma p[_toType(a ,2)->?X]. Extended bui l t-i n _toType/4 to genera te


s i ngl eton ma p

264
OntoBroker 6.3 Appendi x

ObjectLogic syntax Description

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

?- ?M = [a ->[b->{1,2}, c->3], d->4], _ma p2ta bl e(?M,?P,?I,?V).

returns
P I V
---------------
"a .b" 0 1
"a .b" 1 2
"a .c" 0 3
"d" 0 4

?- [a ->1,b->2] == [b->2,a ->1]. _equa l s /2 s houl d be extended to compa re


ma ps i ndependentl y from the order

returns :
true

Si de rema rk: Ma ppi ng ObjectLogi c i ns ta nces to a nd from ma ps


Interes ti ngl y, you ca n a l s o extra ct a l l a ttri bute va l ues of a n ObjectLogi c i ns ta nce i nto a ma p. It “s tri ps ” off the
i ns ta nce a nd l ea ves the bl a nk a ttri bute ma p.

Exa mpl e 1 (fl a t):


juergen[name->"Jürgen", age->28].
?- ?M = collectmap { ?Z | ?Z=[?X,?Y], juergen[?X->?Y] }.

res ul ts i n:
?M = [name->"Jürgen", age->28]

265
OntoBroker 6.3 Appendi x

Exa mpl e 2 (hi era rchi ca l ):


juergen:Person[name->"Jürgen", age->28, address->ja].
ja:Address[street->"An der RaumFabrik", ort->"Durlach"].
?- ?M = collectmap { ?Z
| ((?Z=[?X,?Y], NOT ?Y:?)
OR (?M1 = collectmap {?Z1 | ?Z1=[?X1,?Y1], ?Y[?X1->?Y1]}, ?Y:?), ?Z=[?X,?M1]),
juergen[?X->?Y] }.

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.

ObjectLogic term Description Internal Representation


[] Empty l i s t (s peci a l cons ta nt) []

[->] Empty ma p (s peci a l cons ta nt) [->]

[1,2,3] list $l (1,$l (2,$l (3,[])))

[1|?Y] Li s t hea d / ta i l $l (1,?Y)

[a ->1,b->2] Ma p $m(a ,1,b,2)

[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

Name Arrity Description Parameters

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"]

count 1 counts i tems ["va l ue"]

ma x 1 computes ma xi mum va l ue for i nput va l ues ["va l ue"]

mi n 1 computes mi ni mum va l ue for i nput va l ues ["va l ue"]

s um 1 computes s um of a l l i nput va l ues ["va l ue"]

a vg 1 computes a vera ge of a s et of va l ues ["va l ue"]

col l ectma p 2 col l ects key/va l ue pa i rs i n a ma p ["key","va l ue"]

col l ectba g 1 col l ects a l l i tems i n a l i s t ["key","va l ue"]

col l ects et 1 col l ects a l l di s ti nct i tems i n a l i s t ["key","va l ue"]

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

Name Arrit Description Parameters


y
_reql evel 1 returns the requi rements l evel of the ["requi rements l evel "]
current progra m

_s pa rql query 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
wi th res ul t"]

_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 ql execute 3 executes SQL query ["na me of ta bl e","whi ch


col umns i n whi ch va ri a bl es (e.
g. f(\"ID\",X,\"TYPE\",
Y))","res ource ma na ger key"]

_webs ervi ceAcces s 3 Ca l l s webs ervi ce ["webs ervi ce i nput


ma p","i nput pa ra meter
ma p","output ma p"]

_dba cces s us er 3 gets fa cts from da ta ba s e ["na me of ta bl e","whi ch


col umns i n whi ch va ri a bl es (e.
g. f(\"ID\",X,\"TYPE\",
Y))","Res ourceMa na ger key"]

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"]

_excel a cces s 7 a cces s es MS Excel s prea ds heets ["ma p wi th


res ul t","fi l epa th","s heet-
na me","s ta rt-row","end-
row","s ta rt-col umn","end-
col umn"]

_s pa rql a cces s 4 executes s pa rql a cces ["a ddres s ","l i s t of defa ul t


gra phs ","l i s t of na med
gra phs ","ma p wi th res ul t"]

_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"]

_echoConnector 2 echos i tems of l i s t a s output ["i nput l i s t","output"]

_obquery 3 queri es remote OntoBroker ["Object l ogi c query","ma p wi th


res ul t","connecti on da ta
s ource"]

21.7 Properties Settings


OntoBroker s etti ngs ca n be cha nged i n OntoConfi g.prp fi l e a t the OntoBroker home di rectory.

Property Values Default Value


Ontol ogyLa ngua ge ObjectLogi c, RDF, OWL ObjectLogi c

Stora ge RAM.choos e, RAM.AVL.Pa cked, H2 RAM.choos e

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

BottomUpEva l ua tor choos e, BottomUp2, DBBottomUp, BU3 choos e

Dyna mi cFi l teri ng.Unfol dRul es on, off off

Connector.Ca che.Li feti me query,unl i mi ted. unl i mi ted


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.
unl i mi ted - 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. Ca che
upda te s houl d be done ma nua l l y (s ee "Cl ea r connector
ca che comma nd").
The opti on a ffects a l l connectors .

SPARQL Endpoi nt Spa rql Endpoi nt = on off

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

21.7.1 Start-Up Settings


Parameter Parameter Description
-fenc s tri ng va l ue Fi l e encodi ng

-p number Port (defa ul t: 2267)

-i p <IP a dres s > IP a ddres s to be us ed

-bui l ti nDi r <di rectory na me> di rectory where bui l t-i ns a re l oca ted

-confi gFi l e <fi l e na me> the pl a ce of the confi gura ti on fi l e

-ws port number defi nes the port when s ta rti ng a s


webs ervi ce

-s pa rql Endpoi nt - If l eft uncha nged i n the s etti ngs


(opti on HttpPort), the defa ul t port i s
8267.

-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

-webs ervi ce - s ta rts OntoBroker s erver a s web


s ervi ce

-hel p - s hows the us a ge of the s ta rt-up


s etti ngs

-h s tri ng va l ue hos t on whi ch you s ta rt the s erver e.g.


"l oca l hos t"

-commi tDuri ngImport - s ends a commi t comma nd to the


i nterna l da ta ba s e duri ng i mport a fter
a fi xed s et of a dded fa cts

-X:memorytes t - Sta rts OntoBroker, l oa ded ontol ogi es ,


l ogs the memory cons umpti on a nd
exi ts

-m - ma teri a l i za ti on of the fol l owi ng fi l e


or di rectory

-X:performa ncetes t <s ui te na me> conta i ns the s ui te na me

-X:performa ncetes t: <query fi l e na me> fi l e whi ch conta i ns a s et of queri es


QueryFi l e

-X:performa ncetes t: <output fi l e na me> conta i ns the output da ta


OutputFi l e

-s i l ent - s ta rts OntoBroker wi thout l og output


(s uch a s cons ol e output)

-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

-col l a bs erver - Ena bl es OntoBroker col l a bora ti on


s erver (i mpl i ci tl y s et Indexer = on)

-col l a bs erverNoIndexer - Ena bl es OntoBroker col l a bora ti on


s erver (l ea ves Indexer s etti ngs
uncha nged)

-project <projectFi l e> Us e project fi l e for a dva nced l oa d


confi gura ti on.
269
-webcons ol e - Ena bl es OntoBroker web cons ol e.
The query res ul ts i n the webcons ol e
ca n be copi ed to the cl i pboa rd (e.g.
OntoBroker 6.3 Appendi x

21.7.2 Optimizer Settings


Property Values Default Value
Rewri ter.Shri nkDBAcces s on, off on

Rewri ter.FLToSql DBAcces s Us erRewri ter on, off on

Rewri ter.Redunda ntLi tera l El i mi na tor on, off off

Rewri ter.El i mi na teBodi es on, off off

Rewri ter.Equa l Uni fyRewi ter on, off off

Rewri ter.Propa ga teCons tra i nts on, off on

Rewri ter.Schema Opti mi zer on, off off

Rewri ter.Si mpl eUnfol der on, off off

Rewri ter.Propa ga teCons ta nts on,off on

Rewri ter.Tra ns i ti vi tyRewri ter on,off off

Rewri ter.Fra meOpti mi zer on,off off

Rewri ter.StrongUnfol der on,off off

21.7.3 Tracing and Debugging Settings


Property Values Default Value
Tra ce.Externa l Da ta ba s e on, off off

Tra ce.Externa l Da ta ba s e.SQL on, off off

Tra ce.Sta ti s ti cs .Rul e on, off off

Tra ce.Ma teri a l i za ti on on, off off

Tra ce.Eva l ua ti on off, s i mpl e, rul es , ful l off

Tra ce.Rewri ter on, off off

Tra ce.Rul es on, off on

Tra ce.Queri es on, off off

Tra ce.Da ta model .Cha nges on, off off

Tra ce.Da ta model .Reques ts on, off off

270
OntoBroker 6.3 Appendi x

21.7.4 Performance-Related Settings


Property Values Default Value
ConceptNa mes Ground on, off off

Attri buteNa mes Ground on, off off

Modul eNa mes Ground on, off off

Wel l foundedEva l ua ti on on, off off

El i mi na teDupl i ca tes on, off on

BodyOrderi ng a uto, off a uto

BodyOrderi ngDa ta Fi l e = bodyorderi ng.da ta -

21.7.5 Security (Authentication & Authorization)


Property Values Default Value

Securi ty.Logi nRequi red on, off on

Securi ty.Acces s Control on, off on

21.7.6 Parallelization Settings


Property Values Default Value

Pa ra l l el i ze.ServerComma nds on, off on

Pa ra l l el i ze.ServerComma nds .Ma xThrea ds number, a uto a uto

Pa ra l l el i ze.Loa der on,off on

Pa ra l l el i ze.Loa der.Ma xThrea ds number, a uto a uto

Pa ra l l el i ze.Rea s oner on,off on

Pa ra l l el i ze.Rea s oner.Ma xThrea ds number, a uto a uto

Pa ra l l el i ze.Rea s oner.Connectors .Ma xThrea ds number, a uto a uto

271
OntoBroker 6.3 Appendi x

21.7.7 Materialization Settings


Property Values Default Value
Ma teri a l i ze.ObjectLogi c.Attri buteInheri ta nce on,off off

Ma teri a l i ze.ObjectLogi c.Attri butes on,off off

Ma teri a l i ze.ObjectLogi c.Concepts on, off off

Ma teri a l i ze.ObjectLogi c.Rel a ti ons on,off off

Ma teri a l i ze.ObjectLogi c.RootConcepts on,off off

Ma teri a l i ze.ObjectLogi c.Subcl a s s Tra ns i ti vi ty on,off off

Ma teri a l i ze.ObjectLogi c.Subs etRel a ti ons hi p on,off off

Ma teri a l i ze.ObjectLogi c. on,off off


Structura l Inheri ta nceForIns ta nces

Ma teri a l i ze.ObjectLogi c. on,off off


PropertySubs etRel a ti ons hi p

Ma teri a l i ze.ObjectLogi c.SubpropertyTra ns i ti vi ty on,off off

Ma teri a l i ze.RDF.Hel per.Subcl a s s on,off off

Ma teri a l i ze.RDF.Hel per.Subproperty on,off off

Ma teri a l i ze.RDF.Hel per.Generi c on,off off

Ma teri a l i ze.RDF.Hel per.TypeTemp on,off off

Ma teri a l i ze.RDF.Hel per.Type on,off off

Ma teri a l i ze.RDF.PropertyDef.ByPredi ca te on,off off

Ma teri a l i ze.RDF.PropertyDef.ByDoma i n on,off off

Ma teri a l i ze.RDF.PropertyDef.ByRa nge on,off off

Ma teri a l i ze.RDF.PropertyDef. on,off off


BySubpropertySubject

Ma teri a l i ze.RDF.PropertyDef. on,off off


BySubpropertyObject

Ma teri a l i ze.RDF.Cl a s s Def.ByType on,off off

Ma teri a l i ze.RDF.Cl a s s Def.ByDoma i n on,off off

Ma teri a l i ze.RDF.Cl a s s Def.ByRa nge on,off off

Ma teri a l i ze.RDF.Cl a s s Def.BySubcl a s s Subject on,off off

Ma teri a l i ze.RDF.Cl a s s Def.BySubcl a s s Object on,off off

Ma teri a l i ze.RDF.Enta i l ment.Doma i n on,off off

Ma teri a l i ze.RDF.Enta i l ment.PropertyInheri ta nce on,off off

Ma teri a l i ze.RDF.Enta i l ment.Ra nge on,off off

Ma teri a l i ze.RDF.Enta i l ment.PropertyTra ns i ti vi ty on,off off

Ma teri a l i ze.RDF.Enta i l ment.Cl a s s Inheri ta nce on,off off

Ma teri a l i ze.RDF.Enta i l ment.Cl a s s Tra ns i ti vi ty on,off off

272
OntoBroker 6.3 Appendi x

21.7.8 Logging-Related Settings


Property Values Default Value
LogStra ti fi ca ti onProbl emDeta i l s on, off off

Vi s ua l i zeStra ti fi ca ti onProbl emDeta i l s on, off off

LogPerforma nceWa rni ngs on, off on

21.7.9 Server Settings


Property Values/Description Default Value/Example

Comma ndPort a ny number between 1 a nd 65000 2267

HttpPort a ny number between 1 a nd 65000 8267

FrontSi deCa che on, off off

AJP.Port a ny number between 1 a nd 65000 8009

Col l a bora ti onServer on, off off

RemoteAPI on, off off

WebServi ces on, off off

WebCons ol e on, off off

AJP on, off off

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 .

Externa l DB.MSSQLServer. The va l ues of thes e pa ra meters a re us ed Externa l DB.MSSQLServer.


Col l a ti onOverri de on crea ti ng VARCHAR a nd NVARCHAR Col l a ti onOverri de =
La ti n1_Genera l _CI_AI
Externa l DB.MSSQLServer. col umns i n tempora ry ta bl es , res pecti vel y.
Col l a ti onOverri deN

21.7.10 H2 Storage Options


Property Values Default Value Example
H2.Url URL (onl y l oca l ) - jdbc:h2:fi l e:da ta /edb

H2.Us er ASCII s tri ng sa

H2.Pa s s word ASCII s tri ng

H2.TermCa cheSi ze number 100000

273
OntoBroker 6.3 Appendi x

21.7.11 Fulltext Indexer Settings


Property Values Default Value
Ful l TextIndex on, off on

ena bl es the ful l text i ndex engi ne.


Wi th defa ul t confi gura ti on, ful l text
i ndexes for a l l ontol ogi es a re
a utoma ti ca l l y genera ted a nd ca n be
us ed wi th the
_queryIndex/10 bui l ti n.

Ful l TextIndex.Cha ngeLogInRa m on, off on


Adva nced confi gura ti on opti on to
di s a bl e pers i s tent cha nge l og i f a
pers i s tent
da ta model (i .e. H2) i s us ed. Ha s no
mea ni ng when us i ng a RAM
da ta model

Ful l TextIndex.Di rectory Di rectory to us e for s tori ng the ful l i ndex


text i ndex fi l es .

Ful l TextIndex.NoIndexBui l di ng on, off off


By defa ul t i t i s off (a nd OntoBroker's
beha vi our i s uncha nged).
If i t i s turned on, OntoBroker does
not bui l d or upda tes a ny i ndexes ,
but ca n s ti l l us e the Ful l TextIndex
i nfra s tructure (i ncl us i ve s ea rchi ng
i ndi ces )

Ful l TextIndex.Wa i tOnSta rtup on, off off


If thi s s wi tch i s turned on, the s erver
wa i ts for the end of the i ndexi ng on
s ta rtup, before a ny queri es a nd
comma nds a re executed. Pl ea s e
note, tha t thi s does not a ppl y to
di rect a cces s to the KAON2 API vi a
the Ontol ogyMa na ger.

Ful l TextIndex.Reus eOnRes ta rt on, off off


If thi s s wi tch i s on a nd the
OntoBroker runs wi th a RAM
da ta model (Stora ge = RAM.Choos e,
etc), then the i ndex fi l e a re reus ed
on OntoBroker res ta rt i f the ontol ogy
fi l es a re the s a me a s duri ng the
crea ti on of the i ndex.

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

21.7.11.1 Examples and Scenarios

Scenario for "FullTextIndex.WaitOnStartup":


The ful l text i ndexes a re a l wa ys genera ted a nd upda ted a s ynchronous l y i n the ba ckground. If i t i s i mporta nt
tha t the ful l text i ndex a re compl ete di rectl y a fter the s ta rt of OntoBroker, turn Ful l TextIndex.
Wa i tOnSta rtup=on. In thi s ca s e the OntoBroker wa i ts for compl eti on of i ndex genera ti on on s ta rtup before i t
executes a ny comma nd or queri es .

Scenario for "FullTextIndex.ReuseOnRestart":


If OntoBroker runs i n a rea d-onl y mode, e.g. OntoBroker onl y l oa ds s ome ontol ogi es on s ta rtup a nd then the
ontol ogi es a re not cha nged a nymore (a t l ea s t wi thout s a vi ng them), thi s opti on ca n be us ed to i mprove
s ta rtup ti me. If the ful l text i ndexes ha ve a l rea dy been genera ted, OntoBroker wi l l them reus e them on a
res ta rt wi thout rebui l di ng them.

Configuration example
...

<bean id="ObjectLogicDocumentBuilder" class="com.ontoprise.indexer.flogic.


ObjectLogicStandardObjectDocumentBuilder">
...
<property name="customIndexFields">
<list>
<bean class="com.ontoprise.indexer.objectlogic.CustomIndexField">
<property name="fieldName" value="xname" />
<property name="stored" value="true" />
<property name="attributeNames">
<set>
<value>&lt;http://my.name.space#secondary%20name&gt;</value>
<value>&lt;http://my.name.space#Label&gt;</value>
</set>
</property>
</bean>
</list>
</property>
</bean>
...
In thi s exa mpl e, one cus tom i ndex fi el d wi th the na me "xna me" i s defi ned. The va l ues a re s tored 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). Al l va l ues of the a ttri butes <http://my.na me.s pa ce#s econda ry%20na me> a nd
<http://my.na me.s pa ce#La bel > a re i ndexed for a ny ontol ogy object conta i ni ng s uch a n a ttri bute.

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

CompletionResults results = helper.getCompletion(ontology, options, type, "Transp",


0, 10);
...

21.7.11.2 Custom Index Fields


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.

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

s chema pa th to s chema defi ni ti on, rel a ti ve to conf di rectoy

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

ba tchSi ze number of objects proces s ed i n one ba tch duri ng i ndex crea ti on

fl us hSi ze number of objects proces s ed before fl us hi ng to di s k

wa i tTi me wa i ti ng ti me before s ta rti ng proces s i ng i nva l i da ted objects

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

bool ea nQueryMa xCl a us eCount ma xi mum number of Lucene bool ea n cl a us es

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

Standard index fields


Wi th the defa ul t confi gura ti on, there a re the fol l owi ng i ndex fi el ds a va i l a bl e for every ontol ogy:

276
OntoBroker 6.3 Appendi x

Field name Description

id object i d

lid l oca l na me of 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

a s s ertedi s a a l l concept i ds , thi s object i d (i ns ta nce) ha s a n a s s ertedi s a fa ct,


i .e. ?- $a s s ertedi s a (obj,?V).
i .e. extens i ona l ?- obj:?V.

a xi omtext text of rul es , queri es , a nd cons tra i nts

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)

all a l l text va l ues (va l ues from fi el ds i d, l i d, a xi omtext, s yn)

repr_de, l a ngua ge-dependent repres enta ti on,


repr_en, ...
i .e. extens i ona l va l ue of ?- obj[_repres enta ti on(l a ng)->?V]

docu_de, l a ngua ge-dependent documenta ti on,


docu_en, ...
i .e. extens i ona l va l ue of ?- obj[_documenta ti on(l a ng)->?V]

s yn_de, l a ngua ge-dependent s ynonyms , pl us a l l l a ngua ge-i ndependent s ynonyms


s yn_en, ...
i .e. extens i ona l va l ue of ?- obj[_s ynonym(l a ng)->?V] OR obj[_s ynonym->?V]

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

Custom index fields


You ca n a dd a ddi ti ona l fi el ds by defi ni ng a bea n of cl a s s com.ontopri s e.i ndexer.Ful l TextIndexFi el d.
Ful l TextIndexFi el d ha s the fol l owi ng properti es :

277
OntoBroker 6.3 Appendi x

property name Description

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.

fi el dType na me of fi el d type a s defi ned i n ful l texti ndex-s chema .xml

ontobrokerInterna l fa l s e, defa ul t=fa l s e: Fl a g to ma rk fi el d to be i mporta nt for va ri ous OntoBroker


functi ona l i ti es (Sea rchHel per, Autocompl eteHel per)

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

i ndexed fa l s e: Shoul d fi el d be i ndexed? (overwri tes va l ue from fi el d type)

tokeni zed fa l s e: Shoul d va l ues be tokeni zed? (overwri tes va l ue from fi el d type)

s tored fa l s e: Shoul d va l ue be s tored i n i ndex,i .e. va l ues ca n be retri eved on s ea rch?


(overwri tes va l ue from fi el d type)

bi na ry fa l s e: i s thi s a bi na ry fi el d? (overwri tes va l ue from fi el d type)

compres s ed fa l s e: s houl d s tored text fi el d be compres s ed? (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)

termVectors fa l s e: expert fi el d opti on (s ee Lucene documenta ti on for deta i l s )

termPos i ti ons fa l s e: expert fi el d opti on (s ee Lucene documenta ti on for deta i l s )

termOffs ets fa l s e: expert fi el d opti on (s ee Lucene documenta ti on for deta i l s )

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>&lt;http://my.namespace#name&gt;("$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...

CompletionResults results = helper.getCompletion(ontology, options, type, "Transp",


0, 10);
..

21.7.12 Connector Cache Options


Connector.Da ta ba s e.Ca che.Li feti me query | unl i mi ted

Connector.SPARQL.Ca che.Li feti me query | unl i mi ted

Connector.OntoBroker.Ca che.Li feti me query | unl i mi ted

Connector.Excel .Ca che.Li feti me query | unl i mi ted

Connector.WebServi ce.Ca che.Li feti me query | unl i mi ted

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.

Loggi ng Confi gura ti on 279

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 .

21.8.1 Logged Information


OntoBroker noti fi es a bout cha nges to i ts da ta model by events . Thi s events a nd a ddi ti ona l us er a cti ons ca n
be l ogged. Logged objects i ncl ude i nforma ti on a bout us er, hos t a nd s es s i on i d (i f a va i l a bl e, whi ch hol ds i f
OntoBroker i s confi gured to requi re l ogi ns ). Ea ch l ogged object ha s a ti mes ta mp i ncl udi ng ti me zone
i nforma ti on.

Events
Thi s i s a l i s t of l ogged events :

Event Included information


Ontol ogy ma na ger opened OntoBroker vers i on

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.

Ontol ogy ma na ger cl os ed -

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 crea ted ontol ogy URI

Ontol ogy opened ontol ogy URI


The a xi oms of the opened ontol ogy i ff the a udi t l evel for thi s event
type i s 'deta i l ed'

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'

Ontol ogy cl os ed ontol ogy URI

Ontol ogy del eted ontol ogy URI


The a xi oms of the del eted ontol ogy i ff the a udi t l evel for thi s event
type i s 'deta i l ed'

Ontol ogy rena med (ol d) ontol ogy URI


new ontol ogy URI
Al l ol d 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'

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

Term repl a ced ontol ogy URI


repl a ced term
new term
Al l cha nged a xi oms i ff the a udi t l evel for thi s event type i s 'deta i l ed'

Axi oms upda ted ontol ogy URI


l i s t of cha nged a xi oms

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

Bul k a xi oms upda ted ontol ogy URI


l i s t of bul k cha nges
I.e. a xi oms a re upda ted by
pa tterns .
For ea ch bul k cha nge i n the l i s t:
cha nge type: a dd/remove
a xi om text for query a nd upda te formul a
predi ca te, a rguments , modul e for query a nd upda te formul a , i f the
res pecti ve formul a i s a l i tera l or F-a tom
Al l a dded/removed a xi oms i ff the a udi t l evel for thi s event type i s
'deta i l ed'

Al l a xi oms removed ontol ogy URI


Al l a xi oms previ ous l y conta i ned i n the ontol ogy i ff the a udi t l evel for
thi s event type i s 'deta i l ed'

Na mes pa ce prefi x cha nged ontol ogy URI


prefi x
cha nge type: a dd/remove
na mes pa ce, i f cha nge type i s 'a dd'
ol d na mes pa ce va l ue, i f a ny

Ma teri a l i zed rul es ma teri a l i zed rul es /s ta nda rd a xi oms


fl a g i ndi ca ti ng i f the ma teri a l i zed rul es ha ve been removed from the
ontol ogy
Al l a dded fa cts thru the ma teri a l i za ti on a s wel l a s a l l removed rul es ,
i f a ny, i ff the a udi t l evel for thi s event type i s 'deta i l ed'.

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 .

User action Included information

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 -

Executed comma nd comma nd text

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.

21.8.2 Step by step guide


This chapter helps you to set up the logging functionality of OntoBroker. Follow the steps described below.

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 :

# Enable event logging.


log4j.category.[EVENT]=DEBUG, auditing
log4j.additivity.[EVENT]=false

# To log user actions uncomment the following lines.


log4j.category.[USER_ACTION]=DEBUG, auditing
log4j.additivity.[USER_ACTION]=false

# 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

# Log to the file log/auditing.obl


log4j.appender.auditing=org.apache.log4j.RollingFileAppender
log4j.appender.auditing.MaxFileSize=5MB
log4j.appender.auditing.MaxBackupIndex=20
log4j.appender.auditing.layout=org.apache.log4j.PatternLayout

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

semafora systems GmbH


Wilhelm-Leuschner-Str. 7
64625 Bensheim
Germany

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

© Copyright 2020 SemEO Services GmbH


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express
permission of semafora systems GmbH. The information contained herein may be changed without prior notice.
These materials are subject to change without notice. These materials are provided by semafora systems GmbH
for informational purposes only, without representation or warranty of any kind, and semafora systems GmbH
shall not be liable for errors or omissions with respect to the materials. The only warranties for semafora
systems GmbH products and services are those that are set forth in the express warranty statements
accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.

Parts of the technology and used names in the products OntoStudio andOnto Broker are patent or trademark
protected.

Bensheim, May 2020

286

You might also like