Author: alexdma
Date: Tue Jun 28 10:49:30 2011
New Revision: 1140516
URL: http://svn.apache.org/viewvc?rev=1140516&view=rev
Log:
STANBOL-178 STANBOL-229
- Local fallback, fixes rules/manager unit tests (refactor still to go)
Added:
incubator/stanbol/trunk/rules/manager/src/main/resources/rmi.owl
Modified:
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
incubator/stanbol/trunk/rules/manager/src/main/resources/RuleOntology/TestKReSOntologyRules.owl
incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RuleStoreTest.java
Modified:
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java?rev=1140516&r1=1140515&r2=1140516&view=diff
==============================================================================
---
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
(original)
+++
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/changes/RuleStoreImpl.java
Tue Jun 28 10:49:30 2011
@@ -9,6 +9,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.URL;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashSet;
@@ -23,12 +24,12 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
-import org.apache.stanbol.rules.base.api.Rule;
import org.apache.stanbol.rules.base.api.NoSuchRecipeException;
import org.apache.stanbol.rules.base.api.Recipe;
+import org.apache.stanbol.rules.base.api.Rule;
import org.apache.stanbol.rules.base.api.RuleStore;
-import org.apache.stanbol.rules.base.api.util.RuleList;
import org.apache.stanbol.rules.base.api.util.RecipeList;
+import org.apache.stanbol.rules.base.api.util.RuleList;
import org.apache.stanbol.rules.manager.KB;
import org.apache.stanbol.rules.manager.parse.RuleParserImpl;
import org.osgi.service.component.ComponentContext;
@@ -46,8 +47,10 @@ import org.semanticweb.owlapi.model.OWLN
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyIRIMapper;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+import org.semanticweb.owlapi.util.AutoIRIMapper;
import org.semanticweb.owlapi.util.OWLEntityRemover;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -145,7 +148,13 @@ public class RuleStoreImpl implements Ru
// owlfile.setWritable(true);
OWLOntologyManager owlmanager =
OWLManager.createOWLOntologyManager();
- this.owlmodel =
owlmanager.loadOntologyFromOntologyDocument(IRI.create(owlfile));
+
+ // FIXME : awful
+ URL u = getClass().getResource("/");
+ OWLOntologyIRIMapper mapper = new AutoIRIMapper(new
File(u.toURI()), true);
+ owlmanager.addIRIMapper(mapper);
+
+ this.owlmodel = owlmanager.loadOntology(IRI.create(owlfile));
} catch (Exception io) {
log.error(io.getLocalizedMessage(), io);
Modified:
incubator/stanbol/trunk/rules/manager/src/main/resources/RuleOntology/TestKReSOntologyRules.owl
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/resources/RuleOntology/TestKReSOntologyRules.owl?rev=1140516&r1=1140515&r2=1140516&view=diff
==============================================================================
---
incubator/stanbol/trunk/rules/manager/src/main/resources/RuleOntology/TestKReSOntologyRules.owl
(original)
+++
incubator/stanbol/trunk/rules/manager/src/main/resources/RuleOntology/TestKReSOntologyRules.owl
Tue Jun 28 10:49:30 2011
@@ -21,7 +21,9 @@
<Prefix name="" IRI="http://www.w3.org/2002/07/owl#"/>
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
+ <!--
<Import>http://www.ontologydesignpatterns.org/cp/owl/sequence.owl</Import>
+ -->
<Declaration>
<Class IRI="#KReSRule"/>
</Declaration>
Added: incubator/stanbol/trunk/rules/manager/src/main/resources/rmi.owl
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/resources/rmi.owl?rev=1140516&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/resources/rmi.owl (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/resources/rmi.owl Tue Jun 28
10:49:30 2011
@@ -0,0 +1,290 @@
+<?xml version="1.0"?>
+
+
+<!DOCTYPE rdf:RDF [
+ <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+ <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+ <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+ <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+ <!ENTITY rmi "http://kres.iks-project.eu/ontology/meta/rmi.owl#" >
+ <!ENTITY sequence
"http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#" >
+]>
+
+
+<rdf:RDF xmlns="http://kres.iks-project.eu/ontology/meta/rmi.owl#"
+ xml:base="http://kres.iks-project.eu/ontology/meta/rmi.owl"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+
xmlns:sequence="http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rmi="http://kres.iks-project.eu/ontology/meta/rmi.owl#">
+ <owl:Ontology rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl">
+ <!--
+ <owl:imports
rdf:resource="http://www.ontologydesignpatterns.org/cp/owl/sequence.owl"/>
+ -->
+ </owl:Ontology>
+
+
+
+ <!--
+
///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Annotation properties
+ //
+
///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+ <owl:AnnotationProperty rdf:about="&rdfs;label"/>
+ <owl:AnnotationProperty rdf:about="&rdfs;comment"/>
+
+
+
+ <!--
+
///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Object Properties
+ //
+
///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith -->
+
+ <owl:ObjectProperty rdf:about="&rmi;endWith">
+ <rdfs:label xml:lang="en">end with</rdfs:label>
+ <rdfs:label xml:lang="it">finisce con</rdfs:label>
+ <rdfs:comment xml:lang="en">This property identifies the final rule of
a recipe.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa proprietà identific la regola
con cui termina la ricettà.</rdfs:comment>
+ <rdfs:range rdf:resource="&rmi;KReSRule"/>
+ <rdfs:domain rdf:resource="&rmi;Recipe"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
+ </owl:ObjectProperty>
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule -->
+
+ <owl:ObjectProperty rdf:about="&rmi;hasRule">
+ <rdfs:label xml:lang="en">has rule</rdfs:label>
+ <rdfs:label xml:lang="it">ha regola</rdfs:label>
+ <rdfs:comment xml:lang="en">This property links a Recipe istance to
one o more KReS rules.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa proprietà lega una ricetta ad
una o più regole.</rdfs:comment>
+ <rdfs:range rdf:resource="&rmi;KReSRule"/>
+ <rdfs:domain rdf:resource="&rmi;Recipe"/>
+ <owl:inverseOf rdf:resource="&rmi;isRuleOf"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
+ </owl:ObjectProperty>
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#isRuleOf -->
+
+ <owl:ObjectProperty rdf:about="&rmi;isRuleOf">
+ <rdfs:label xml:lang="en">is rule of</rdfs:label>
+ <rdfs:label xml:lang="it">è regola di</rdfs:label>
+ <rdfs:comment xml:lang="en">This is the inverse of hasRule. Link the
rule to one or more recipes.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa proprietà è l'inversa
di "hasRule".</rdfs:comment>
+ <rdfs:domain rdf:resource="&rmi;KReSRule"/>
+ <rdfs:range rdf:resource="&rmi;Recipe"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
+ </owl:ObjectProperty>
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith -->
+
+ <owl:ObjectProperty rdf:about="&rmi;startWith">
+ <rdfs:label xml:lang="en">start with</rdfs:label>
+ <rdfs:label xml:lang="it">inizia con</rdfs:label>
+ <rdfs:comment xml:lang="en">This property idntifies the starting rule
of a recipe.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa proprietà identifica la regola
con cui inizia un recipe.</rdfs:comment>
+ <rdfs:range rdf:resource="&rmi;KReSRule"/>
+ <rdfs:domain rdf:resource="&rmi;Recipe"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
+ </owl:ObjectProperty>
+
+
+
+ <!--
http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes -->
+
+ <owl:ObjectProperty rdf:about="&sequence;directlyPrecedes"/>
+
+
+
+ <!-- http://www.w3.org/2002/07/owl#topObjectProperty -->
+
+ <owl:ObjectProperty rdf:about="&owl;topObjectProperty"/>
+
+
+
+ <!--
+
///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Data properties
+ //
+
///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead -->
+
+ <owl:DatatypeProperty rdf:about="&rmi;hasBodyAndHead">
+ <rdfs:label xml:lang="en">has body and head</rdfs:label>
+ <rdfs:label xml:lang="it">ha corpo e testa</rdfs:label>
+ <rdfs:comment xml:lang="en">Physical Storage of a rule. Here there is
the kres rule string or a rule in some other syntax.</rdfs:comment>
+ <rdfs:comment xml:lang="it">La regola viene conservata fisicamente
secondo un corpo ed una testa. La sintassi può essere KReS o SWRL o
un'altra sintassi legibile dal ragionatore.</rdfs:comment>
+ <rdfs:domain rdf:resource="&rmi;KReSRule"/>
+ <rdfs:range rdf:resource="&xsd;string"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
+ </owl:DatatypeProperty>
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription -->
+
+ <owl:DatatypeProperty rdf:about="&rmi;hasDescription">
+ <rdfs:label xml:lang="en">has description</rdfs:label>
+ <rdfs:label xml:lang="it">ha descrizione</rdfs:label>
+ <rdfs:comment xml:lang="en">To add some description to rules or
recipes.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Aggiungere una descrizione alle regole o
alle ricette</rdfs:comment>
+ <rdfs:range rdf:resource="&xsd;string"/>
+ <rdfs:domain rdf:resource="&owl;Thing"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
+ </owl:DatatypeProperty>
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence -->
+
+ <owl:DatatypeProperty rdf:about="&rmi;hasSequence">
+ <rdfs:label xml:lang="en">has sequence</rdfs:label>
+ <rdfs:label xml:lang="it">ha sequenza</rdfs:label>
+ <rdfs:comment xml:lang="en">Define the rule sequence of a recipe on
the form: <rule-IRI1>, <rule-IRI2>, etc. N.B. The sequence can be
retrievied also via query SPARQL by following object properties.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Definisce la sequenza delle regole nella
forma: <rule-IRI1>, <rule-IRI2>, etc. N.B. La sequenza può
anche essere recuperata via query SPARQL sequendo le proprietà
dell'oggetto.</rdfs:comment>
+ <rdfs:domain rdf:resource="&rmi;Recipe"/>
+ <rdfs:range rdf:resource="&xsd;string"/>
+ <rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
+ </owl:DatatypeProperty>
+
+
+
+ <!-- http://www.w3.org/2002/07/owl#topDataProperty -->
+
+ <owl:DatatypeProperty rdf:about="&owl;topDataProperty"/>
+
+
+
+ <!--
+
///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Classes
+ //
+
///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule -->
+
+ <owl:Class rdf:about="&rmi;KReSRule">
+ <rdfs:label xml:lang="en">KReS rule</rdfs:label>
+ <rdfs:label xml:lang="it">regole KReS</rdfs:label>
+ <rdfs:subClassOf rdf:resource="&owl;Thing"/>
+ <rdfs:subClassOf>
+ <owl:Restriction>
+ <owl:onProperty rdf:resource="&rmi;isRuleOf"/>
+ <owl:someValuesFrom rdf:resource="&rmi;Recipe"/>
+ </owl:Restriction>
+ </rdfs:subClassOf>
+ <owl:disjointWith rdf:resource="&rmi;Recipe"/>
+ <rdfs:comment xml:lang="en">This class contains the IRI (the name)
that identifies the rule.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa classe contiene gli IRI che
identificano le regole (i nomi) su una o più ontologie.</rdfs:comment>
+ </owl:Class>
+
+
+
+ <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe -->
+
+ <owl:Class rdf:about="&rmi;Recipe">
+ <rdfs:label xml:lang="en">Recipe</rdfs:label>
+ <rdfs:label xml:lang="it">Ricetta</rdfs:label>
+ <rdfs:subClassOf rdf:resource="&owl;Thing"/>
+ <rdfs:comment xml:lang="en">This class contains the IRI that
identifies a sequence of rules to perform particular action on the dataset. It
must have at least one KReS rule.</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa classe contiene l'IRI che
identifica una sequenza di regole che eseguirano una particolare azione sul
dataset. L'istanza di questa classe deve contenere almeno una regola
KReS.</rdfs:comment>
+ </owl:Class>
+
+
+
+ <!-- http://www.w3.org/2002/07/owl#Thing -->
+
+ <owl:Class rdf:about="&owl;Thing"/>
+
+
+
+ <!--
+
///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Annotations
+ //
+
///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#KReSRule">
+ <rdfs:label xml:lang="en">SWRL rules</rdfs:label>
+ <rdfs:label xml:lang="it">regole SWRL</rdfs:label>
+ <rdfs:comment xml:lang="en">This class contains the IRI (the name)
that identifies the rule. </rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa classe contiene gli IRI che
identificano le regole (i nomi) su una o più ontologie. </rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#hasDescription">
+ <rdfs:label xml:lang="en">has description</rdfs:label>
+ <rdfs:label xml:lang="it">ha descrizione</rdfs:label>
+ <rdfs:comment xml:lang="en">Any kind of description about rules or
recipes.</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#Recipe">
+ <rdfs:label xml:lang="en">Receipt</rdfs:label>
+ <rdfs:label xml:lang="it">Ricevere</rdfs:label>
+ <rdfs:comment xml:lang="en">This class contains the IRI that
identifies a sequence of rules to perform particular action on the dataset. It
must have at least one KReS rule</rdfs:comment>
+ <rdfs:comment xml:lang="it">Questa classe contiene l'IRI che
identifica una sequenza di regole che eseguirano una particolare azione sul
dataset. L'istanza di questa classe deve contenere almeno una regola
KReS</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#endWith">
+ <rdfs:label xml:lang="en">end with</rdfs:label>
+ <rdfs:label xml:lang="it">finisce con</rdfs:label>
+ <rdfs:comment xml:lang="en">This property indentifies the last rule of
the recipe.</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#hasSequence">
+ <rdfs:label xml:lang="en">has sequence</rdfs:label>
+ <rdfs:label xml:lang="it">ha sequenza</rdfs:label>
+ <rdfs:comment xml:lang="en">Define the rule sequence of a
recipe.</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#hasBodyAndHead">
+ <rdfs:label xml:lang="en">has body and head</rdfs:label>
+ <rdfs:label xml:lang="it">ha corpo e testa</rdfs:label>
+ <rdfs:comment xml:lang="en">Physical Storage of a rule. Here there is
the kres rule string.</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#hasRule">
+ <rdfs:label xml:lang="en">has rule</rdfs:label>
+ <rdfs:label xml:lang="it">ha regola</rdfs:label>
+ <rdfs:comment xml:lang="en">This property links a Recipe istance to a
KReS rule.</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#isRuleOf">
+ <rdfs:label xml:lang="en">is rule of</rdfs:label>
+ <rdfs:label xml:lang="it">è regola di</rdfs:label>
+ <rdfs:comment xml:lang="en">This property links a KReS rule to a
Recipe</rdfs:comment>
+ </rdf:Description>
+ <rdf:Description
rdf:about="http://www.semanticweb.org/ontologies/ontologyrules.owl#startWith">
+ <rdfs:label xml:lang="en">start with</rdfs:label>
+ <rdfs:label xml:lang="it">inizia con</rdfs:label>
+ <rdfs:comment xml:lang="en">This property identifies the starting rule
of the recipe.</rdfs:comment>
+ </rdf:Description>
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.0.0.1451)
http://owlapi.sourceforge.net -->
+
Modified:
incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RuleStoreTest.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RuleStoreTest.java?rev=1140516&r1=1140515&r2=1140516&view=diff
==============================================================================
---
incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RuleStoreTest.java
(original)
+++
incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/RuleStoreTest.java
Tue Jun 28 10:49:30 2011
@@ -26,6 +26,7 @@ import org.semanticweb.owlapi.apibinding
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.util.AutoIRIMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,12 +68,13 @@ public class RuleStoreTest {
public RuleStore store = null, blankStore = null;
@Test
- public void testKReSRuleStore(){
+ public void testKReSRuleStore() throws Exception {
OWLOntology owlmodel = store.getOntology();
log.debug("Path for default store config is "
+ blankStore.getFilePath());
assertNotNull(owlmodel);
OWLOntologyManager owlmanager =
OWLManager.createOWLOntologyManager();
+ owlmanager.addIRIMapper(new AutoIRIMapper(new
File("./src/main/resources/RuleOntology/"), false));
String src = "";
try{
src =
"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl";
@@ -91,7 +93,7 @@ public class RuleStoreTest {
}
@Test
- public void testKReSRuleStore_2(){
+ public void testKReSRuleStore_2() throws Exception {
OWLOntology owlmodel = blankStore.getOntology();
System.out.println("Path for default store config is "
+ blankStore.getFilePath());