You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Enrico Daga <en...@gmail.com> on 2010/12/29 19:20:30 UTC

Re: svn commit: r1053689 [1/6] - in /incubator/stanbol/trunk/kres: eu.iksproject.kres.api/ eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/ eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/ eu.

The tidying was needed, elsewhere the patch posted in STANBOL-10 would
not be accepted by SVN.
This is why I did the conversion of line endings.
The changes have been commented in the related issue.

Please tell me if I misunderstood something.
Enrico

On 29 December 2010 19:12, Upayavira <uv...@odoko.co.uk> wrote:
> Please keep 'code tidying' commits and actual code change commits
> separate, otherwise it can be difficult to review the changes - e.g.
> what of this commit is actual change?
>
> Thanks,
>
> Upaayvira
>
>
> On Wed, 29 Dec 2010 18:04 +0000, enridaga@apache.org wrote:
>> Author: enridaga
>> Date: Wed Dec 29 18:04:19 2010
>> New Revision: 1053689
>>
>> URL: http://svn.apache.org/viewvc?rev=1053689&view=rev
>> Log:
>> STANBOL-10
>> Applying patch posted by Alessandro Adamou.
>> Before that, applied a conversion for consistent line ending.
>>
>> Added:
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/resources/META-INF/conf/catalog.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/KReSConf/
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/KReSConf/rmi_config.owl
>> Modified:
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Enrichment.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMOntResource.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMRootResource.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMScopeOntologyResource.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMScopeResource.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/Activator.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ONManager.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/io/OntologyRegistryIRISource.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/AbstractOntologySpaceImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/CoreOntologySpaceImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/CustomOntologySpaceImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyIndexImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyScopeFactoryImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyScopeImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologySpaceFactoryImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/SessionOntologySpaceImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/registry/model/impl/RegistryLoader.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/session/KReSSessionManagerImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/session/ScopeSessionSynchronizer.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/util/OntologyUtils.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/org/stlab/xd/utils/RDFSLabelGetter.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/Namespace.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestIndexing.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestOntologyScope.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestOntologySpaces.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/registry/TestRegistry.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/session/TestSessions.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.ontologies/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.reasoners/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.reasoners/src/main/java/eu/iksproject/kres/reasoners/KReSReasonerImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSAddRecipe.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSRuleStore.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSSetRuleStore.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/resources/RuleOntology/rmi_config.owl
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSAddRecipeTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSAddRuleTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSGetRecipeTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSGetRuleTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSLoadRuleFileTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRemoveRecipeTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRemoveRuleTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRuleStoreTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.manager/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.manager/src/main/java/eu/iksproject/kres/semion/manager/SemionManagerImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/test/java/eu/iksproject/kres/semion/reengineer/db/DBExtractorTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/test/java/eu/iksproject/kres/semion/reengineer/xml/XMLReengineerTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/hermit124/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/mysql/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/owlapi3/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/owllink102/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/xerces/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/transformation/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage.provider/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage.provider/src/main/java/eu/iksproject/kres/storage/provider/OntologyStorageProviderImpl.java
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage/pom.xml
>>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage/src/main/java/eu/iksproject/kres/storage/ClerezzaStorage.java
>>
>> Modified: incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> --- incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
>> (original)
>> +++ incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml Wed Dec
>> 29 18:04:19 2010
>> @@ -7,14 +7,14 @@
>>       <parent>
>>               <groupId>eu.iksproject</groupId>
>>               <artifactId>eu.iksproject.kres.parent</artifactId>
>> -               <version>0.6-SNAPSHOT</version>
>> +               <version>0.7</version>
>>               <relativePath>../parent/pom.xml</relativePath>
>>       </parent>
>>
>>       <groupId>eu.iksproject</groupId>
>>       <artifactId>eu.iksproject.kres.api</artifactId>
>>       <packaging>bundle</packaging>
>> -       <version>0.6-SNAPSHOT</version>
>> +       <version>${kres-version}</version>
>>
>>       <name>IKS KReS API</name>
>>       <description>KReS API</description>
>> @@ -23,7 +23,7 @@
>>
>>       <properties>
>>               <jersey-version>1.1.5.1</jersey-version>
>> -               <kres-version>0.6-SNAPSHOT</kres-version>
>> +               <kres-version>0.7</kres-version>
>>               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>       </properties>
>>
>> @@ -36,7 +36,7 @@
>>                               <configuration>
>>                                       <instructions>
>>                                               <Export-Package>
>> -
>> eu.iksproject.kres.api.*;version=${pom.version},
>> +
>> eu.iksproject.kres.api.*;version=${kres-version},
>>                                                       com.hp.hpl.jena.*,
>>                                                       com.ibm.icu.*,
>>                                                       com.sun.jersey.*,
>>
>> Added:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java?rev=1053689&view=auto
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> (added)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> Wed Dec 29 18:04:19 2010
>> @@ -0,0 +1,17 @@
>> +package eu.iksproject.kres.api.manager.ontology;
>> +
>> +public enum SpaceType {
>> +
>> +       CORE("core"), CUSTOM("custom"), SESSION("session");
>> +
>> +       private SpaceType(String suffix) {
>> +               this.suffix = suffix;
>> +       }
>> +
>> +       private String suffix;
>> +
>> +       public String getIRISuffix() {
>> +               return suffix;
>> +       }
>> +
>> +}
>>
>> Modified:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> (original)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> Wed Dec 29 18:04:19 2010
>> @@ -26,7 +26,7 @@ public interface KReSRegistryLoader {
>>
>>       public boolean hasLibrary(Registry reg, IRI libraryID);
>>
>> -       public boolean isPrintingLoadedOntologies();
>> +//     public boolean isPrintingLoadedOntologies();
>>
>>       public void loadLocations() throws RegistryContentException;
>>
>> @@ -40,5 +40,5 @@ public interface KReSRegistryLoader {
>>        */
>>       public Set<Registry> loadRegistriesEager(IRI physicalIRI);
>>
>> -       public void setPrintLoadedOntologies(boolean doPrint);
>> +//     public void setPrintLoadedOntologies(boolean doPrint);
>>  }
>>
>> Added:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl?rev=1053689&view=auto
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> (added)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> Wed Dec 29 18:04:19 2010
>> @@ -0,0 +1,174 @@
>> +<?xml version="1.0"?>
>> +<rdf:RDF
>> xmlns="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#"
>> +     xml:base="http://kres.iks-project.eu/ontology/meta/rmi_config.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_config.owl">
>> +        <owl:imports
>> rdf:resource="http://ontologydesignpatterns.org/ont/iks/kres/rmi.owl"/>
>> +    </owl:Ontology>
>> +
>> +
>> +
>> +    <!--
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +    //
>> +    // Object Properties
>> +    //
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +     -->
>> +
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith -->
>> +
>> +    <owl:ObjectProperty
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith"/>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule -->
>> +
>> +    <owl:ObjectProperty
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"/>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith -->
>> +
>> +    <owl:ObjectProperty
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith"/>
>> +
>> +
>> +
>> +    <!--
>> http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes
>> -->
>> +
>> +    <owl:ObjectProperty
>> rdf:about="http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"/>
>> +
>> +
>> +
>> +    <!--
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +    //
>> +    // Data properties
>> +    //
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +     -->
>> +
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead
>> -->
>> +
>> +    <owl:DatatypeProperty
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"/>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription
>> -->
>> +
>> +    <owl:DatatypeProperty
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription"/>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence
>> -->
>> +
>> +    <owl:DatatypeProperty
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence"/>
>> +
>> +
>> +
>> +    <!--
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +    //
>> +    // Classes
>> +    //
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +     -->
>> +
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule -->
>> +
>> +    <owl:Class
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe -->
>> +
>> +    <owl:Class
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
>> +
>> +
>> +
>> +    <!--
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +    //
>> +    // Individuals
>> +    //
>> +
>> ///////////////////////////////////////////////////////////////////////////////////////
>> +     -->
>> +
>> +
>> +
>> +
>> +    <!--
>> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA -->
>> +
>> +    <owl:NamedIndividual
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA">
>> +        <rdf:type
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
>> +        <rmi:hasDescription
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Some description
>> here</rmi:hasDescription>
>> +        <rmi:hasSequence
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://eu.iksproject.kres/KReSOntologyRules.owl#MyRuleB,http://eu.iksproject.kres/KReSOntologyRules.owl#MyRuleA</rmi:hasSequence>
>> +        <rmi:hasRule
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
>> +        <rmi:endWith
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
>> +        <rmi:hasRule
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB"/>
>> +        <rmi:startWith
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB"/>
>> +    </owl:NamedIndividual>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA
>> -->
>> +
>> +    <owl:NamedIndividual
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA">
>> +        <rdf:type
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> +        <rmi:hasDescription
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example of
>> description for my rule A</rmi:hasDescription>
>> +        <rmi:hasBodyAndHead
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BodyA -&gt;
>> BodyB</rmi:hasBodyAndHead>
>> +    </owl:NamedIndividual>
>> +
>> +
>> +
>> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB
>> -->
>> +
>> +    <owl:NamedIndividual
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB">
>> +        <rdf:type
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> +        <rmi:hasDescription
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example of
>> description..for my rule B</rmi:hasDescription>
>> +        <rmi:hasBodyAndHead
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BodyB -&gt;
>> HeadB</rmi:hasBodyAndHead>
>> +        <sequence:directlyPrecedes
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
>> +    </owl:NamedIndividual>
>> +
>> +
>> +
>> +    <!--
>> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRecipe
>> -->
>> +
>> +    <owl:NamedIndividual
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRecipe">
>> +        <rdf:type
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
>> +        <rmi:hasDescription
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A single rule
>> recipe.</rmi:hasDescription>
>> +        <rmi:hasSequence
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule</rmi:hasSequence>
>> +        <rmi:endWith
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
>> +        <rmi:hasRule
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
>> +        <rmi:startWith
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
>> +    </owl:NamedIndividual>
>> +
>> +
>> +
>> +    <!--
>> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule
>> -->
>> +
>> +    <owl:NamedIndividual
>> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule">
>> +        <rdf:type
>> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> +        <rmi:hasDescription
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A rule to
>> inference if a person has an uncle.</rmi:hasDescription>
>> +        <rmi:hasBodyAndHead
>> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ProvaParent =
>> &lt;http://www.semanticweb.org/ontologies/2010/6/ProvaParent.owl#&gt; .
>> rule1[ has(ProvaParent:hasParent, ?x, ?y) . has(ProvaParent:hasBrother,
>> ?y, ?z) -&gt; has(ProvaParent:hasUncle, ?x, ?z) ]</rmi:hasBodyAndHead>
>> +    </owl:NamedIndividual>
>> +</rdf:RDF>
>> +
>> +
>> +
>> +<!-- Generated by the OWL API (version 3.0.0.1413)
>> http://owlapi.sourceforge.net -->
>> +
>>
>> Modified: incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> --- incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
>> (original)
>> +++ incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml Wed
>> Dec 29 18:04:19 2010
>> @@ -7,13 +7,13 @@
>>       <parent>
>>               <groupId>eu.iksproject</groupId>
>>               <artifactId>eu.iksproject.kres.parent</artifactId>
>> -               <version>0.6-SNAPSHOT</version>
>> +               <version>0.7</version>
>>               <relativePath>../parent/pom.xml</relativePath>
>>       </parent>
>>
>>       <groupId>eu.iksproject</groupId>
>>       <artifactId>eu.iksproject.kres.jersey</artifactId>
>> -       <version>0.6-SNAPSHOT</version>
>> +       <version>${kres-version}</version>
>>       <packaging>bundle</packaging>
>>
>>       <name>IKS KReS Jersey JAX-RS API and front-end</name>
>> @@ -22,7 +22,8 @@
>>       <properties>
>>               <jersey-version>1.1.5.1</jersey-version>
>>               <pax-exam-version>1.2.0</pax-exam-version>
>> -               <kres-version>0.6-SNAPSHOT</kres-version>
>> +               <kres-version>0.7</kres-version>
>> +
>> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>       </properties>
>>
>>       <dependencies>
>> @@ -252,6 +253,12 @@
>>              <scope>provided</scope>
>>           </dependency>
>>               <dependency>
>> +                       <groupId>eu.iksproject</groupId>
>> +
>> <artifactId>eu.iksproject.kres.storage.provider</artifactId>
>> +                       <version>${kres-version}</version>
>> +                       <scope>provided</scope>
>> +               </dependency>
>> +               <dependency>
>>                       <groupId>com.hp.hpl.jena</groupId>
>>                       <artifactId>jena</artifactId>
>>                       <version>2.6.2</version>
>>
>> Modified:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> (original)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> Wed Dec 29 18:04:19 2010
>> @@ -5,19 +5,14 @@
>>
>>  package eu.iksproject.kres.jersey.manager;
>>
>> -import eu.iksproject.kres.api.rules.RuleStore;
>> -import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> -import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> -import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> -import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> -import eu.iksproject.kres.api.format.KReSFormat;
>>  import java.util.HashMap;
>> +import java.util.Hashtable;
>>  import java.util.Iterator;
>>  import java.util.LinkedList;
>>  import java.util.List;
>>  import java.util.Set;
>>  import java.util.Vector;
>> +
>>  import javax.servlet.ServletContext;
>>  import javax.ws.rs.Consumes;
>>  import javax.ws.rs.DELETE;
>> @@ -33,8 +28,8 @@ import javax.ws.rs.core.Context;
>>  import javax.ws.rs.core.MediaType;
>>  import javax.ws.rs.core.Response;
>>  import javax.ws.rs.core.Response.Status;
>> +
>>  import org.semanticweb.owlapi.apibinding.OWLManager;
>> -import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
>>  import org.semanticweb.owlapi.model.AddImport;
>>  import org.semanticweb.owlapi.model.IRI;
>>  import org.semanticweb.owlapi.model.OWLDataFactory;
>> @@ -45,59 +40,102 @@ import org.semanticweb.owlapi.model.OWLO
>>  import org.semanticweb.owlapi.model.OWLOntology;
>>  import org.semanticweb.owlapi.model.OWLOntologyChange;
>>  import org.semanticweb.owlapi.model.OWLOntologyStorageException;
>> +import org.slf4j.Logger;
>> +import org.slf4j.LoggerFactory;
>>
>> -import com.sun.jersey.api.view.ImplicitProduces;
>> +import eu.iksproject.kres.api.format.KReSFormat;
>> +import eu.iksproject.kres.api.manager.KReSONManager;
>> +import eu.iksproject.kres.api.rules.RuleStore;
>> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>> +import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> +import eu.iksproject.kres.manager.ONManager;
>> +import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> +import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> +import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>>
>>  /**
>>   *
>>   * @author elvio
>>   */
>> -@Path("/recipe")///{uri:.+}")
>> +@Path("/recipe")
>> +// /{uri:.+}")
>>  //@ImplicitProduces(MediaType.TEXT_HTML + ";qs=2")
>>  public class Recipe extends NavigationMixin{
>>
>> +       protected KReSONManager onm;
>> +
>> +       private Logger log = LoggerFactory.getLogger(getClass());
>> +
>>      private RuleStore kresRuleStore;
>> +       private OntologyStoreProvider storeProvider;
>>
>>     /**
>>       * To get the KReSRuleStore where are stored the rules and the
>>       recipes
>>       *
>> -     * @param servletContext {To get the context where the REST service
>> is running.}
>> +        * @param servletContext
>> +        *            {To get the context where the REST service is
>> running.}
>>       */
>>      public Recipe(@Context ServletContext servletContext){
>> -       this.kresRuleStore = (RuleStore)
>> servletContext.getAttribute(RuleStore.class.getName());
>> +               this.kresRuleStore = (RuleStore) servletContext
>> +                               .getAttribute(RuleStore.class.getName());
>> +               this.onm = (KReSONManager) servletContext
>> +
>> .getAttribute(KReSONManager.class.getName());
>> +               this.storeProvider = (OntologyStoreProvider)
>> servletContext
>> +
>> .getAttribute(OntologyStoreProvider.class.getName());
>> +               // Contingency code for missing components follows.
>> +               /*
>> +                * FIXME! The following code is required only for the
>> tests. This should
>> +                * be removed and the test should work without this code.
>> +                */
>> +               if (storeProvider == null) {
>> +                       log
>> +                                       .warn("No OntologyStoreProvider
>> in servlet context. Instantiating manually...");
>> +                       storeProvider = new
>> OntologyStorageProviderImpl();
>> +               }
>> +               if (onm == null) {
>> +                       log
>> +                                       .warn("No KReSONManager in
>> servlet context. Instantiating manually...");
>> +                       onm = new
>> ONManager(storeProvider.getActiveOntologyStorage(),
>> +                                       new Hashtable<String, Object>());
>> +               }
>>         if (kresRuleStore == null) {
>> -           System.err.println("WARNING: KReSRuleStore with stored rules
>> and recipes is missing in ServletContext. A new instance has been
>> created.");
>> -           this.kresRuleStore = new KReSRuleStore("");
>> -           System.err.println("PATH TO OWL FILE LOADED:
>> "+kresRuleStore.getFilePath());
>> -            /*throw new IllegalStateException(
>> -                    "KReSRuleStore with stored rules and recipes is
>> missing in ServletContext");*/
>> +                       log
>> +                                       .warn("No KReSRuleStore with
>> stored rules and recipes found in servlet context. Instantiating manually
>> with default values...");
>> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> +                                       new Hashtable<String, Object>(),
>> "");
>> +                       log
>> +                                       .debug("PATH TO OWL FILE LOADED:
>> "
>> +                                                       +
>> kresRuleStore.getFilePath());
>>          }
>>      }
>>
>>     /**
>> -     * Get a recipe with its rules from the rule base (that is the
>> ontology that contains the rules and the recipe).
>> +        * Get a recipe with its rules from the rule base (that is the
>> ontology that
>> +        * contains the rules and the recipe).
>>       *
>> -     * @param uri {A string contains the IRI full name of the recipe.}
>> +        * @param uri
>> +        *            {A string contains the IRI full name of the
>> recipe.}
>>       * @return Return: <br/>
>> -     *       200 The recipe is retrieved (import declarations point to
>> KReS Services) <br/>
>> +        *         200 The recipe is retrieved (import declarations point
>> to KReS
>> +        *         Services) <br/>
>>       *       404 The recipe does not exists in the manager <br/>
>>       *       500 Some error occurred
>>       *
>>       */
>>      @GET
>>      @Path("/{uri:.+}")
>> -    @Produces(value={KReSFormat.RDF_XML,
>> -                                KReSFormat.TURTLE,
>> -                                KReSFormat.OWL_XML,
>> -                                KReSFormat.FUNCTIONAL_OWL,
>> -                                KReSFormat.MANCHESTER_OWL,
>> -                                KReSFormat.RDF_JSON})
>> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> +                       KReSFormat.OWL_XML, KReSFormat.FUNCTIONAL_OWL,
>> +                       KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON })
>>      public Response getRecipe(@PathParam("uri") String uri){
>>        try{
>>
>>         KReSGetRecipe rule = new KReSGetRecipe(kresRuleStore);
>>
>> -       //String ID =
>> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> +                       // String ID =
>> +                       //
>> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>>
>>         if(uri.equals("all")){
>>
>> @@ -108,32 +146,48 @@ public class Recipe extends NavigationMi
>>              return Response.status(Status.NOT_FOUND).build();
>>          }else{
>>
>> -            //The recipe is retrieved (import declarations point to KReS
>> Services)
>> +                                       // The recipe is retrieved
>> (import declarations point to
>> +                                       // KReS Services)
>>              OWLOntology onto = kresRuleStore.getOntology();
>> -            OWLOntology newmodel =
>> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> -            OWLDataFactory factory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> +                                       OWLOntology newmodel = OWLManager
>> +
>> .createOWLOntologyManager().createOntology(
>> +
>> onto.getOntologyID());
>> +                                       OWLDataFactory factory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>>
>> -            Iterator<OWLOntology> importedonto =
>> onto.getDirectImports().iterator();
>> +                                       Iterator<OWLOntology>
>> importedonto = onto
>> +
>> .getDirectImports().iterator();
>>              List<OWLOntologyChange> additions = new
>>              LinkedList<OWLOntologyChange>();
>> -            OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> +                                       OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>>
>>              while(importedonto.hasNext()){
>>                  OWLOntology auxonto = importedonto.next();
>> -                additions.add(new
>> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                               additions.add(new
>> AddImport(newmodel, auxfactory
>> +
>> .getOWLImportsDeclaration(auxonto
>> +
>>       .getOWLOntologyManager()
>> +
>>       .getOntologyDocumentIRI(auxonto))));
>>              }
>>
>>              if(!additions.isEmpty())
>> -
>> newmodel.getOWLOntologyManager().applyChanges(additions);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .applyChanges(additions);
>>
>>              for(int i = 0; i<recipe.size(); i++){
>> -                OWLNamedIndividual ind =
>> factory.getOWLNamedIndividual(recipe.get(i));
>> +                                               OWLNamedIndividual ind =
>> factory
>> +
>> .getOWLNamedIndividual(recipe.get(i));
>>                  Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .addAxioms(newmodel, ax);
>>
>>              }
>>
>>              try {
>> -
>> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> System.out);
>> +
>> OWLManager.createOWLOntologyManager().saveOntology(
>> +                                                               newmodel,
>> +
>> newmodel.getOWLOntologyManager()
>> +
>>       .getOntologyFormat(newmodel),
>> +
>> System.out);
>>               } catch (OWLOntologyStorageException e) {
>>                       // TODO Auto-generated catch block
>>                       e.printStackTrace();
>> @@ -150,30 +204,44 @@ public class Recipe extends NavigationMi
>>              //The recipe deos not exists in the manager
>>              return Response.status(Status.NOT_FOUND).build();
>>          }else{
>> -            //The recipe is retrieved (import declarations point to KReS
>> Services)
>> +                                       // The recipe is retrieved
>> (import declarations point to
>> +                                       // KReS Services)
>>              OWLOntology onto = kresRuleStore.getOntology();
>>
>> -            OWLDataFactory factory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> -            OWLObjectProperty prop =
>> factory.getOWLObjectProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> -            OWLNamedIndividual ind =
>> factory.getOWLNamedIndividual(IRI.create(uri));
>> -            Set<OWLIndividual> value = ind.getObjectPropertyValues(prop,
>> onto);
>> +                                       OWLDataFactory factory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>> +                                       OWLObjectProperty prop = factory
>> +
>> .getOWLObjectProperty(IRI
>> +
>> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> +                                       OWLNamedIndividual ind =
>> factory.getOWLNamedIndividual(IRI
>> +                                                       .create(uri));
>> +                                       Set<OWLIndividual> value =
>> ind.getObjectPropertyValues(
>> +                                                       prop, onto);
>>              Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>>
>>              Iterator<OWLIndividual> iter = value.iterator();
>>
>> -            OWLOntology newmodel =
>> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> +                                       OWLOntology newmodel = OWLManager
>> +
>> .createOWLOntologyManager().createOntology(
>> +
>> onto.getOntologyID());
>>
>> -            Iterator<OWLOntology> importedonto =
>> onto.getDirectImports().iterator();
>> +                                       Iterator<OWLOntology>
>> importedonto = onto
>> +
>> .getDirectImports().iterator();
>>              List<OWLOntologyChange> additions = new
>>              LinkedList<OWLOntologyChange>();
>> -            OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> +                                       OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>>
>>              while(importedonto.hasNext()){
>>                  OWLOntology auxonto = importedonto.next();
>> -                additions.add(new
>> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                               additions.add(new
>> AddImport(newmodel, auxfactory
>> +
>> .getOWLImportsDeclaration(auxonto
>> +
>>       .getOWLOntologyManager()
>> +
>>       .getOntologyDocumentIRI(auxonto))));
>>              }
>>
>>              if(!additions.isEmpty())
>> -
>> newmodel.getOWLOntologyManager().applyChanges(additions);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .applyChanges(additions);
>>
>>              newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>>
>> @@ -182,11 +250,16 @@ public class Recipe extends NavigationMi
>>                  ind = (OWLNamedIndividual) iter.next();
>>                  ax = onto.getAxioms(ind);
>>
>> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .addAxioms(newmodel, ax);
>>              }
>>
>>              try {
>> -
>> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> System.out);
>> +
>> OWLManager.createOWLOntologyManager().saveOntology(
>> +                                                               newmodel,
>> +
>> newmodel.getOWLOntologyManager()
>> +
>>       .getOntologyFormat(newmodel),
>> +
>> System.out);
>>               } catch (OWLOntologyStorageException e) {
>>                       // TODO Auto-generated catch block
>>                       e.printStackTrace();
>> @@ -204,8 +277,11 @@ public class Recipe extends NavigationMi
>>
>>     /**
>>       * To add a recipe without rules.
>> -     * @param recipe {A string contains the IRI of the recipe to be
>> added}
>> -     * @param description {A string contains a description of the rule}
>> +        *
>> +        * @param recipe
>> +        *            {A string contains the IRI of the recipe to be
>> added}
>> +        * @param description
>> +        *            {A string contains a description of the rule}
>>       * @return Return: <br/>
>>       *      200 The recipe has been added<br/>
>>       *      409 The recipe has not been added<br/>
>> @@ -213,21 +289,21 @@ public class Recipe extends NavigationMi
>>       */
>>      @POST
>>      @Consumes(MediaType.MULTIPART_FORM_DATA)
>> -    @Produces(value={KReSFormat.RDF_XML,
>> -                                KReSFormat.TURTLE,
>> -                                KReSFormat.OWL_XML,
>> -                                KReSFormat.FUNCTIONAL_OWL,
>> -                                KReSFormat.MANCHESTER_OWL,
>> -                                KReSFormat.RDF_JSON})
>> -    public Response addRecipe(@FormParam(value="recipe") String
>> recipe,@FormParam(value="description") String description){
>> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> +                       KReSFormat.OWL_XML, KReSFormat.FUNCTIONAL_OWL,
>> +                       KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON })
>> +       public Response addRecipe(@FormParam(value = "recipe") String
>> recipe,
>> +                       @FormParam(value = "description") String
>> description) {
>>
>>          try{
>>
>>              KReSAddRecipe instance = new KReSAddRecipe(kresRuleStore);
>>
>> -            //String ID =
>> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> +                       // String ID =
>> +                       //
>> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>>
>> -            boolean ok = instance.addSimpleRecipe(IRI.create(recipe),
>> description);
>> +                       boolean ok =
>> instance.addSimpleRecipe(IRI.create(recipe),
>> +                                       description);
>>
>>                  if(!ok){
>>
>> @@ -245,9 +321,10 @@ public class Recipe extends NavigationMi
>>
>>     /**
>>       * To delete a recipe
>> -     * @param recipe {A tring contains an IRI of the recipe}
>> -     * @return
>> -     *      200 The recipe has been deleted<br/>
>> +        *
>> +        * @param recipe
>> +        *            {A tring contains an IRI of the recipe}
>> +        * @return 200 The recipe has been deleted<br/>
>>       *      409 The recipe has not been deleted<br/>
>>       *      500 Some error occurred
>>       */
>> @@ -260,7 +337,8 @@ public class Recipe extends NavigationMi
>>
>>              KReSRemoveRecipe instance = new
>>              KReSRemoveRecipe(kresRuleStore);
>>
>> -            //String ID =
>> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> +                       // String ID =
>> +                       //
>> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>>
>>              boolean ok = instance.removeRecipe(IRI.create(recipe));
>>
>>
>> Modified:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> (original)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> Wed Dec 29 18:04:19 2010
>> @@ -5,27 +5,16 @@
>>
>>  package eu.iksproject.kres.jersey.manager;
>>
>> -import eu.iksproject.kres.api.rules.RuleStore;
>> -import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> -import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> -import eu.iksproject.kres.rules.manager.KReSAddRule;
>> -import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> -import eu.iksproject.kres.rules.manager.KReSGetRule;
>> -import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> -import eu.iksproject.kres.rules.manager.KReSRemoveRule;
>> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> -import eu.iksproject.kres.api.format.KReSFormat;
>> -
>>  import java.io.UnsupportedEncodingException;
>>  import java.net.URLEncoder;
>> -import java.util.ArrayList;
>> -import java.util.Collection;
>>  import java.util.HashMap;
>> +import java.util.Hashtable;
>>  import java.util.Iterator;
>>  import java.util.LinkedList;
>>  import java.util.List;
>>  import java.util.Set;
>>  import java.util.Vector;
>> +
>>  import javax.servlet.ServletContext;
>>  import javax.ws.rs.Consumes;
>>  import javax.ws.rs.DELETE;
>> @@ -42,24 +31,32 @@ import javax.ws.rs.core.MediaType;
>>  import javax.ws.rs.core.Response;
>>  import javax.ws.rs.core.Response.Status;
>>
>> -import org.codehaus.jettison.json.JSONArray;
>>  import org.semanticweb.owlapi.apibinding.OWLManager;
>> -import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
>> -import org.semanticweb.owlapi.model.AddAxiom;
>>  import org.semanticweb.owlapi.model.AddImport;
>>  import org.semanticweb.owlapi.model.IRI;
>> -import org.semanticweb.owlapi.model.OWLAxiom;
>>  import org.semanticweb.owlapi.model.OWLDataFactory;
>> -import org.semanticweb.owlapi.model.OWLIndividual;
>>  import org.semanticweb.owlapi.model.OWLIndividualAxiom;
>>  import org.semanticweb.owlapi.model.OWLNamedIndividual;
>> -import org.semanticweb.owlapi.model.OWLObjectProperty;
>> -import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
>>  import org.semanticweb.owlapi.model.OWLOntology;
>>  import org.semanticweb.owlapi.model.OWLOntologyChange;
>> -import org.semanticweb.owlapi.model.OWLOntologyCreationException;
>> -import org.semanticweb.owlapi.model.OWLOntologyManager;
>>  import org.semanticweb.owlapi.model.OWLOntologyStorageException;
>> +import org.slf4j.Logger;
>> +import org.slf4j.LoggerFactory;
>> +
>> +import eu.iksproject.kres.api.format.KReSFormat;
>> +import eu.iksproject.kres.api.manager.KReSONManager;
>> +import eu.iksproject.kres.api.rules.RuleStore;
>> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>> +import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> +import eu.iksproject.kres.manager.ONManager;
>> +import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> +import eu.iksproject.kres.rules.manager.KReSAddRule;
>> +import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> +import eu.iksproject.kres.rules.manager.KReSGetRule;
>> +import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> +import eu.iksproject.kres.rules.manager.KReSRemoveRule;
>> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>>
>>  /**
>>   *
>> @@ -70,40 +67,74 @@ import org.semanticweb.owlapi.model.OWLO
>>  @Path("/rule")
>>  public class Rule extends NavigationMixin{
>>
>> -    private static RuleStore kresRuleStore;
>> +       protected KReSONManager onm;
>> +       protected OntologyStoreProvider storeProvider;
>> +
>> +       private Logger log = LoggerFactory.getLogger(getClass());
>> +
>> +       private RuleStore kresRuleStore;
>>      private HashMap<IRI, String> map;
>>      private String desc;
>>
>>     /**
>>       * To get the KReSRuleStore where are stored the rules and the
>>       recipes
>>       *
>> -     * @param servletContext {To get the context where the REST service
>> is running.}
>> +        * @param servletContext
>> +        *            {To get the context where the REST service is
>> running.}
>>       */
>>      public Rule(@Context ServletContext servletContext){
>> -       this.kresRuleStore = (RuleStore)
>> servletContext.getAttribute(RuleStore.class.getName());
>> -
>> +               this.kresRuleStore = (RuleStore) servletContext
>> +                               .getAttribute(RuleStore.class.getName());
>> +               this.onm = (KReSONManager) servletContext
>> +
>> .getAttribute(KReSONManager.class.getName());
>> +               this.storeProvider = (OntologyStoreProvider)
>> servletContext
>> +
>> .getAttribute(OntologyStoreProvider.class.getName());
>> +               // Contingency code for missing components follows.
>> +               /*
>> +                * FIXME! The following code is required only for the
>> tests. This should
>> +                * be removed and the test should work without this code.
>> +                */
>> +               if (storeProvider == null) {
>> +                       log
>> +                                       .warn("No OntologyStoreProvider
>> in servlet context. Instantiating manually...");
>> +                       storeProvider = new
>> OntologyStorageProviderImpl();
>> +               }
>> +               if (onm == null) {
>> +                       log
>> +                                       .warn("No KReSONManager in
>> servlet context. Instantiating manually...");
>> +                       onm = new
>> ONManager(storeProvider.getActiveOntologyStorage(),
>> +                                       new Hashtable<String, Object>());
>> +               }
>>         if (kresRuleStore == null) {
>> -           System.err.println("WARNING: KReSRuleStore with stored rules
>> and recipes is missing in ServletContext. A new instance has been
>> created.");
>> -           this.kresRuleStore = new KReSRuleStore("");
>> -           System.err.println("PATH TO OWL FILE LOADED:
>> "+kresRuleStore.getFilePath());
>> -            /*throw new IllegalStateException(
>> -                    "KReSRuleStore with stored rules and recipes is
>> missing in ServletContext");*/
>> +                       log
>> +                                       .warn("No KReSRuleStore with
>> stored rules and recipes found in servlet context. Instantiating manually
>> with default values...");
>> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> +                                       new Hashtable<String, Object>(),
>> "");
>> +                       log
>> +                                       .debug("PATH TO OWL FILE LOADED:
>> "
>> +                                                       +
>> kresRuleStore.getFilePath());
>>          }
>>      }
>>
>>     /**
>> -     * Get a rule from the rule base (that is the ontology that contains
>> the rules and the recipe).
>> -     * curl -v -X GET
>> http://localhost:8080/kres/rule/http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule
>> -     * @param uri {A string contains the IRI full name of the rule.}
>> +        * Get a rule from the rule base (that is the ontology that
>> contains the
>> +        * rules and the recipe). curl -v -X GET
>> +        * http://localhost:8080/kres/rule/http
>> +        * ://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule
>> +        *
>> +        * @param uri
>> +        *            {A string contains the IRI full name of the rule.}
>>       * @return Return: <br/>
>> -     *       200 The rule is retrieved (import declarations point to
>> KReS Services) <br/>
>> +        *         200 The rule is retrieved (import declarations point
>> to KReS
>> +        *         Services) <br/>
>>       *       404 The rule does not exists in the manager <br/>
>>       *       500 Some error occurred
>>       *
>>       */
>>      @GET
>>      @Path("/{uri:.+}")
>> -
>> @Produces(value={KReSFormat.RDF_XML,KReSFormat.TURTLE,KReSFormat.OWL_XML})
>> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> +                       KReSFormat.OWL_XML })
>>      public Response getRule(@PathParam("uri") String uri){
>>
>>        try{
>> @@ -119,29 +150,44 @@ public class Rule extends NavigationMixi
>>          }else{
>>
>>              OWLOntology onto = kresRuleStore.getOntology();
>> -            OWLOntology newmodel =
>> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> -            OWLDataFactory factory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> +                                       OWLOntology newmodel = OWLManager
>> +
>> .createOWLOntologyManager().createOntology(
>> +
>> onto.getOntologyID());
>> +                                       OWLDataFactory factory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>>
>> -            Iterator<OWLOntology> importedonto =
>> onto.getDirectImports().iterator();
>> +                                       Iterator<OWLOntology>
>> importedonto = onto
>> +
>> .getDirectImports().iterator();
>>              List<OWLOntologyChange> additions = new
>>              LinkedList<OWLOntologyChange>();
>> -            OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> +                                       OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>>
>>              while(importedonto.hasNext()){
>>                  OWLOntology auxonto = importedonto.next();
>> -                additions.add(new
>> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                               additions.add(new
>> AddImport(newmodel, auxfactory
>> +
>> .getOWLImportsDeclaration(auxonto
>> +
>>       .getOWLOntologyManager()
>> +
>>       .getOntologyDocumentIRI(auxonto))));
>>              }
>>
>>              if(!additions.isEmpty())
>> -
>> newmodel.getOWLOntologyManager().applyChanges(additions);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .applyChanges(additions);
>>
>>              while(keys.hasNext()){
>> -                OWLNamedIndividual ind =
>> factory.getOWLNamedIndividual(keys.next());
>> +                                               OWLNamedIndividual ind =
>> factory
>> +
>> .getOWLNamedIndividual(keys.next());
>>                  Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .addAxioms(newmodel, ax);
>>              }
>>
>>              try {
>> -
>> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> System.out);
>> +
>> OWLManager.createOWLOntologyManager().saveOntology(
>> +                                                               newmodel,
>> +
>> newmodel.getOWLOntologyManager()
>> +
>>       .getOntologyFormat(newmodel),
>> +
>> System.out);
>>               } catch (OWLOntologyStorageException e) {
>>                       // TODO Auto-generated catch block
>>                       e.printStackTrace();
>> @@ -159,27 +205,41 @@ public class Rule extends NavigationMixi
>>          }else{
>>              OWLOntology onto = kresRuleStore.getOntology();
>>
>> -            OWLDataFactory factory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> -            OWLNamedIndividual ind =
>> factory.getOWLNamedIndividual(IRI.create(uri));
>> +                                       OWLDataFactory factory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>> +                                       OWLNamedIndividual ind =
>> factory.getOWLNamedIndividual(IRI
>> +                                                       .create(uri));
>>              Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> -            OWLOntology newmodel =
>> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> +                                       OWLOntology newmodel = OWLManager
>> +
>> .createOWLOntologyManager().createOntology(
>> +
>> onto.getOntologyID());
>>
>> -            Iterator<OWLOntology> importedonto =
>> onto.getDirectImports().iterator();
>> +                                       Iterator<OWLOntology>
>> importedonto = onto
>> +
>> .getDirectImports().iterator();
>>              List<OWLOntologyChange> additions = new
>>              LinkedList<OWLOntologyChange>();
>> -            OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager().getOWLDataFactory();
>> +                                       OWLDataFactory auxfactory =
>> onto.getOWLOntologyManager()
>> +
>> .getOWLDataFactory();
>>
>>              while(importedonto.hasNext()){
>>                  OWLOntology auxonto = importedonto.next();
>> -                additions.add(new
>> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                               additions.add(new
>> AddImport(newmodel, auxfactory
>> +
>> .getOWLImportsDeclaration(auxonto
>> +
>>       .getOWLOntologyManager()
>> +
>>       .getOntologyDocumentIRI(auxonto))));
>>              }
>>
>>              if(!additions.isEmpty())
>> -
>> newmodel.getOWLOntologyManager().applyChanges(additions);
>> +
>> newmodel.getOWLOntologyManager()
>> +
>> .applyChanges(additions);
>>
>>              newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>>
>>              try {
>> -
>> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> System.out);
>> +
>> OWLManager.createOWLOntologyManager().saveOntology(
>> +                                                               newmodel,
>> +
>> newmodel.getOWLOntologyManager()
>> +
>>       .getOntologyFormat(newmodel),
>> +
>> System.out);
>>               } catch (OWLOntologyStorageException e) {
>>                       // TODO Auto-generated catch block
>>                       e.printStackTrace();
>> @@ -197,15 +257,16 @@ public class Rule extends NavigationMixi
>>
>>      @GET
>>      @Path("/of-recipe/{uri:.+}")
>> -    @Produces(value={KReSFormat.RDF_XML,
>> -                                KReSFormat.RDF_JSON})
>> -
>> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.RDF_JSON })
>>      public Response getRulesOfRecipe(@PathParam("uri") String
>>      recipeURI){
>>
>>       KReSGetRule kReSGetRule = new KReSGetRule(kresRuleStore);
>>       String recipeURIEnc;
>>               try {
>> -                       recipeURIEnc =
>> URLEncoder.encode("http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA",
>> "UTF-8");
>> +                       recipeURIEnc = URLEncoder
>> +                                       .encode(
>> +
>> "http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA",
>> +                                                       "UTF-8");
>>                       System.out.println("RECIPE : "+recipeURIEnc);
>>               } catch (UnsupportedEncodingException e) {
>>                       // TODO Auto-generated catch block
>> @@ -213,19 +274,32 @@ public class Rule extends NavigationMixi
>>               }
>>
>>       System.out.println("RECIPE IRI : "+IRI.create(recipeURI).toString());
>> -       OWLOntology ontology =
>> kReSGetRule.getAllRulesOfARecipe(IRI.create(recipeURI));
>> +               OWLOntology ontology =
>> kReSGetRule.getAllRulesOfARecipe(IRI
>> +                               .create(recipeURI));
>>
>>       return Response.ok(ontology).build();
>>
>> -
>>      }
>> +
>>     /**
>> -     * To add a rule to a recipe at the end of the sequence.
>> -     * curl -v -X POST -F
>> "recipe=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaParentRecipe"
>> -F "rule=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaRuleNEW"
>> -F "kres-syntax=body -> head" -F "description=prova di aggiunta regola"
>> http://localhost:8080/kres/rule
>> -     * @param recipe {A string contains the IRI of the recipe where to
>> add the rule}
>> -     * @param rule {A string contains the IRI of the rule to be added at
>> the recipe}
>> -     * @param kres_syntax {A string contains the body and the head of
>> the kres rule. If not specified the rule is search in the Ontology
>> otherwise is added as new.}
>> -     * @param description {A string contains a description of the rule}
>> +        * To add a rule to a recipe at the end of the sequence. curl -v
>> -X POST -F
>> +        *
>> "recipe=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaParentRecipe"
>> +        * -F
>> "rule=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaRuleNEW"
>> +        * -F "kres-syntax=body -> head" -F "description=prova di
>> aggiunta regola"
>> +        * http://localhost:8080/kres/rule
>> +        *
>> +        * @param recipe
>> +        *            {A string contains the IRI of the recipe where to
>> add the
>> +        *            rule}
>> +        * @param rule
>> +        *            {A string contains the IRI of the rule to be added
>> at the
>> +        *            recipe}
>> +        * @param kres_syntax
>> +        *            {A string contains the body and the head of the
>> kres rule. If
>> +        *            not specified the rule is search in the Ontology
>> otherwise is
>> +        *            added as new.}
>> +        * @param description
>> +        *            {A string contains a description of the rule}
>>       * @return Return: <br/>
>>       *      200 The rule has been added <br/>
>>       *      204 The rule has not been added <br/>
>> @@ -236,7 +310,10 @@ public class Rule extends NavigationMixi
>>       */
>>      @POST
>>      @Consumes(MediaType.MULTIPART_FORM_DATA)
>> -    public Response addRuleToRecipe(@FormParam(value="recipe") String
>> recipe,@FormParam(value="rule") String
>> rule,@FormParam(value="kres-syntax") String
>> kres_syntax,@FormParam(value="description") String description){
>> +       public Response addRuleToRecipe(@FormParam(value = "recipe")
>> String recipe,
>> +                       @FormParam(value = "rule") String rule,
>> +                       @FormParam(value = "kres-syntax") String
>> kres_syntax,
>> +                       @FormParam(value = "description") String
>> description) {
>>
>>  //        System.err.println("recipe "+recipe);
>>  //        System.err.println("rule " + rule);
>> @@ -306,7 +383,8 @@ public class Rule extends NavigationMixi
>>           if((kres_syntax!=null)&(description!=null)){
>>              //Get the rule
>>              KReSAddRule inrule = new KReSAddRule(kresRuleStore);
>> -            boolean ok =
>> inrule.addRule(IRI.create(rule),kres_syntax,description);
>> +                               boolean ok =
>> inrule.addRule(IRI.create(rule), kres_syntax,
>> +                                               description);
>>              if(!ok){
>>                  System.err.println("PROBLEM TO ADD: "+rule);
>>                  return Response.status(Status.CONFLICT).build();
>> @@ -341,7 +419,6 @@ public class Rule extends NavigationMixi
>>                  return Response.status(Status.CONFLICT).build();
>>              }
>>
>> -
>>              //Add the recipe with the new rule
>>              KReSAddRecipe newadd = new KReSAddRecipe(kresRuleStore);
>>              ok = newadd.addRecipe(IRI.create(recipe), ruleseq, desc);
>> @@ -361,14 +438,17 @@ public class Rule extends NavigationMixi
>>      }
>>
>>     /**
>> -     * To delete a rule from a recipe or from the ontology. If the
>> recipe is not specified the rule is deleted from the ontology.
>> -     * curl -v -X DELETE -G \
>> -     * -d
>> recipe="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRecipe"
>> \
>> -     * -d
>> rule="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentNewRule"
>> \
>> +        * To delete a rule from a recipe or from the ontology. If the
>> recipe is not
>> +        * specified the rule is deleted from the ontology. curl -v -X
>> DELETE -G \
>> +        * -d recipe=
>> +        *
>> "http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRecipe" \ -d
>> +        * rule
>> +        *
>> ="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentNewRule" \
>>       * http://localhost:port/kres/rule
>>      *
>>       * @Param rule {A string contains an IRI of the rule to be removed}
>> -     * @param recipe {A string contains an IRI of the recipe where
>> remove the rule}
>> +        * @param recipe
>> +        *            {A string contains an IRI of the recipe where
>> remove the rule}
>>       * @return Return: <br/>
>>       *      200 The rule has been deleted<br/>
>>       *      204 The rule has not been deleted<br/>
>> @@ -379,7 +459,8 @@ public class Rule extends NavigationMixi
>>      @DELETE
>>      //@Consumes(MediaType.TEXT_PLAIN)
>>      @Produces(KReSFormat.TEXT_PLAIN)
>> -    public Response removeRule(@QueryParam(value="rule") String
>> rule,@QueryParam(value="recipe") String recipe){
>> +       public Response removeRule(@QueryParam(value = "rule") String
>> rule,
>> +                       @QueryParam(value = "recipe") String recipe) {
>>
>>          boolean ok;
>>
>> @@ -408,7 +489,8 @@ public class Rule extends NavigationMixi
>>              }
>>
>>              KReSRemoveRule remove = new KReSRemoveRule(kresRuleStore);
>> -            ok =
>> remove.removeRuleFromRecipe(IRI.create(rule),IRI.create(recipe));
>> +                               ok =
>> remove.removeRuleFromRecipe(IRI.create(rule), IRI
>> +                                               .create(recipe));
>>              if(ok){
>>                  kresRuleStore.saveOntology();
>>                  return Response.status(Status.OK).build();
>>
>> Modified:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> (original)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> Wed Dec 29 18:04:19 2010
>> @@ -5,31 +5,14 @@
>>
>>  package eu.iksproject.kres.jersey.reasoners;
>>
>> -import com.hp.hpl.jena.rdf.model.Model;
>> -import com.hp.hpl.jena.rdf.model.ModelFactory;
>> -import com.hp.hpl.jena.rdf.model.Resource;
>> -import eu.iksproject.kres.api.format.KReSFormat;
>> -import eu.iksproject.kres.api.manager.ontology.OntologyScope;
>> -import eu.iksproject.kres.api.manager.ontology.OntologySpace;
>> -import eu.iksproject.kres.api.manager.ontology.ScopeRegistry;
>> -import eu.iksproject.kres.api.manager.ontology.SessionOntologySpace;
>> -import eu.iksproject.kres.api.rules.KReSRule;
>> -import eu.iksproject.kres.api.rules.NoSuchRecipeException;
>> -import eu.iksproject.kres.api.rules.RuleStore;
>> -import eu.iksproject.kres.api.rules.util.KReSRuleList;
>> -import eu.iksproject.kres.manager.ONManager;
>> -import eu.iksproject.kres.reasoners.KReSCreateReasoner;
>> -import eu.iksproject.kres.reasoners.KReSRunReasoner;
>> -import eu.iksproject.kres.reasoners.KReSRunRules;
>> -import eu.iksproject.kres.rules.KReSKB;
>> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> -import eu.iksproject.kres.rules.parser.KReSRuleParser;
>>  import java.io.File;
>>  import java.net.URL;
>> +import java.util.Hashtable;
>>  import java.util.Iterator;
>>  import java.util.LinkedList;
>>  import java.util.List;
>>  import java.util.Set;
>> +
>>  import javax.servlet.ServletContext;
>>  import javax.ws.rs.Consumes;
>>  import javax.ws.rs.FormParam;
>> @@ -41,6 +24,7 @@ import javax.ws.rs.core.Context;
>>  import javax.ws.rs.core.MediaType;
>>  import javax.ws.rs.core.Response;
>>  import javax.ws.rs.core.Response.Status;
>> +
>>  import org.semanticweb.owlapi.apibinding.OWLManager;
>>  import org.semanticweb.owlapi.model.AddImport;
>>  import org.semanticweb.owlapi.model.IRI;
>> @@ -55,7 +39,32 @@ import org.semanticweb.owlapi.model.OWLO
>>  import org.semanticweb.owlapi.model.OWLOntologyChange;
>>  import org.semanticweb.owlapi.model.OWLOntologyManager;
>>  import org.semanticweb.owlapi.reasoner.InconsistentOntologyException;
>> +import org.slf4j.Logger;
>> +import org.slf4j.LoggerFactory;
>>
>> +import com.hp.hpl.jena.rdf.model.Model;
>> +import com.hp.hpl.jena.rdf.model.ModelFactory;
>> +import com.hp.hpl.jena.rdf.model.Resource;
>> +
>> +import eu.iksproject.kres.api.format.KReSFormat;
>> +import eu.iksproject.kres.api.manager.KReSONManager;
>> +import eu.iksproject.kres.api.manager.ontology.OntologyScope;
>> +import eu.iksproject.kres.api.manager.ontology.OntologySpace;
>> +import eu.iksproject.kres.api.manager.ontology.ScopeRegistry;
>> +import eu.iksproject.kres.api.manager.ontology.SessionOntologySpace;
>> +import eu.iksproject.kres.api.rules.KReSRule;
>> +import eu.iksproject.kres.api.rules.NoSuchRecipeException;
>> +import eu.iksproject.kres.api.rules.RuleStore;
>> +import eu.iksproject.kres.api.rules.util.KReSRuleList;
>> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>> +import eu.iksproject.kres.manager.ONManager;
>> +import eu.iksproject.kres.reasoners.KReSCreateReasoner;
>> +import eu.iksproject.kres.reasoners.KReSRunReasoner;
>> +import eu.iksproject.kres.reasoners.KReSRunRules;
>> +import eu.iksproject.kres.rules.KReSKB;
>> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> +import eu.iksproject.kres.rules.parser.KReSRuleParser;
>> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>>
>>  /**
>>   *
>> @@ -68,49 +77,94 @@ public class Classify {
>>       private OWLOntology inputowl;
>>       private OWLOntology scopeowl;
>>
>> +       protected KReSONManager onm;
>> +       protected OntologyStoreProvider storeProvider;
>> +
>> +       private Logger log = LoggerFactory.getLogger(getClass());
>> +
>>      /**
>>       * To get the KReSRuleStore where are stored the rules and the
>>       recipes
>>       *
>> -     * @param servletContext {To get the context where the REST service
>> is running.}
>> +        * @param servletContext
>> +        *            {To get the context where the REST service is
>> running.}
>>       */
>>      public Classify(@Context ServletContext servletContext){
>> -       this.kresRuleStore = (RuleStore)
>> servletContext.getAttribute(RuleStore.class.getName());
>> +               this.kresRuleStore = (RuleStore) servletContext
>> +                               .getAttribute(RuleStore.class.getName());
>> +               this.onm = (KReSONManager) servletContext
>> +
>> .getAttribute(KReSONManager.class.getName());
>> +               this.storeProvider = (OntologyStoreProvider)
>> servletContext
>> +
>> .getAttribute(OntologyStoreProvider.class.getName());
>> +               // Contingency code for missing components follows.
>> +               /*
>> +                * FIXME! The following code is required only for the
>> tests. This should
>> +                * be removed and the test should work without this code.
>> +                */
>> +               if (storeProvider == null) {
>> +                       log
>> +                                       .warn("No OntologyStoreProvider
>> in servlet context. Instantiating manually...");
>> +                       storeProvider = new
>> OntologyStorageProviderImpl();
>> +               }
>> +               if (onm == null) {
>> +                       log
>> +                                       .warn("No KReSONManager in
>> servlet context. Instantiating manually...");
>> +                       onm = new
>> ONManager(storeProvider.getActiveOntologyStorage(),
>> +                                       new Hashtable<String, Object>());
>> +               }
>>         if (kresRuleStore == null) {
>> -            System.err.println("WARNING: KReSRuleStore with stored rules
>> and recipes is missing in ServletContext. A new instance has been
>> created.");
>> -            this.kresRuleStore = new KReSRuleStore("");
>> -            System.err.println("PATH TO OWL FILE LOADED:
>> "+kresRuleStore.getFilePath());
>> -//            throw new IllegalStateException(
>> -//                    "KReSRuleStore with stored rules and recipes is
>> missing in ServletContext");
>> +                       log
>> +                                       .warn("No KReSRuleStore with
>> stored rules and recipes found in servlet context. Instantiating manually
>> with default values...");
>> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> +                                       new Hashtable<String, Object>(),
>> "");
>> +                       log
>> +                                       .debug("PATH TO OWL FILE LOADED:
>> "
>> +                                                       +
>> kresRuleStore.getFilePath());
>>          }
>>      }
>>
>>       /**
>>       * To trasform a sequence of rules to a Jena Model
>> -     * @param owl {OWLOntology object contains a single recipe}
>> +        *
>> +        * @param owl
>> +        *            {OWLOntology object contains a single recipe}
>>       * @return {A jena rdf model contains the SWRL rule.}
>>       */
>> -    private Model fromRecipeToModel(OWLOntology owl) throws
>> NoSuchRecipeException{
>> +       private Model fromRecipeToModel(OWLOntology owl)
>> +                       throws NoSuchRecipeException {
>>
>> -        RuleStore store = new KReSRuleStore(owl);
>> +               // FIXME: why the heck is this method re-instantiating a
>> rule store?!?
>> +               RuleStore store = new KReSRuleStore(onm,
>> +                               new Hashtable<String, Object>(), owl);
>>          Model jenamodel = ModelFactory.createDefaultModel();
>>
>> -        OWLDataFactory factory =
>> owl.getOWLOntologyManager().getOWLDataFactory();
>> -        OWLClass ontocls =
>> factory.getOWLClass(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"));
>> +               OWLDataFactory factory = owl.getOWLOntologyManager()
>> +                               .getOWLDataFactory();
>> +               OWLClass ontocls = factory
>> +                               .getOWLClass(IRI
>> +
>> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"));
>>          Set<OWLClassAssertionAxiom> cls =
>>          owl.getClassAssertionAxioms(ontocls);
>>          Iterator<OWLClassAssertionAxiom> iter = cls.iterator();
>>          IRI recipeiri =
>>          IRI.create(iter.next().getIndividual().toStringID());
>>
>> -       OWLIndividual recipeIndividual =
>> factory.getOWLNamedIndividual(recipeiri);
>> +               OWLIndividual recipeIndividual = factory
>> +                               .getOWLNamedIndividual(recipeiri);
>>
>> -       OWLObjectProperty objectProperty =
>> factory.getOWLObjectProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> -       Set<OWLIndividual> rules =
>> recipeIndividual.getObjectPropertyValues(objectProperty,
>> store.getOntology());
>> +               OWLObjectProperty objectProperty = factory
>> +                               .getOWLObjectProperty(IRI
>> +
>> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> +               Set<OWLIndividual> rules =
>> recipeIndividual.getObjectPropertyValues(
>> +                               objectProperty, store.getOntology());
>>          String kReSRules = "";
>>          for(OWLIndividual rule : rules){
>> -                       OWLDataProperty hasBodyAndHead =
>> factory.getOWLDataProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"));
>> -                       Set<OWLLiteral> kReSRuleLiterals =
>> rule.getDataPropertyValues(hasBodyAndHead, store.getOntology());
>> +                       OWLDataProperty hasBodyAndHead = factory
>> +                                       .getOWLDataProperty(IRI
>> +
>> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"));
>> +                       Set<OWLLiteral> kReSRuleLiterals =
>> rule.getDataPropertyValues(
>> +                                       hasBodyAndHead,
>> store.getOntology());
>>
>>                       for(OWLLiteral kReSRuleLiteral : kReSRuleLiterals){
>> -                               kReSRules += kReSRuleLiteral.getLiteral()
>> + System.getProperty("line.separator");
>> +                               kReSRules += kReSRuleLiteral.getLiteral()
>> +                                               +
>> System.getProperty("line.separator");
>>                       }
>>               }
>>
>> @@ -128,13 +182,24 @@ public class Classify {
>>      }
>>
>>     /**
>> -     * To run a classifying reasoner on a RDF input File or IRI on the
>> base of a Scope (or an ontology) and a recipe. Can be used either HermiT
>> or an owl-link server reasoner end-point
>> -     * @param session {A string contains the session IRI used to
>> classify the input.}
>> -     * @param scope {A string contains either a specific scope's
>> ontology or the scope IRI used to classify the input.}
>> -     * @param recipe {A string contains the recipe IRI from the service
>> http://localhost:port/kres/recipe/recipeName.}
>> +        * To run a classifying reasoner on a RDF input File or IRI on
>> the base of a
>> +        * Scope (or an ontology) and a recipe. Can be used either HermiT
>> or an
>> +        * owl-link server reasoner end-point
>> +        *
>> +        * @param session
>> +        *            {A string contains the session IRI used to classify
>> the
>> +        *            input.}
>> +        * @param scope
>> +        *            {A string contains either a specific scope's
>> ontology or the
>> +        *            scope IRI used to classify the input.}
>> +        * @param recipe
>> +        *            {A string contains the recipe IRI from the service
>> +        *            http://localhost:port/kres/recipe/recipeName.}
>>       * @Param file {A file in a RDF (eihter RDF/XML or owl) to be
>>       classified.}
>> -     * @Param input_graph {A string contains the IRI of RDF (either
>> RDF/XML or OWL) to be classified.}
>> -     * @Param owllink_endpoint {A string contains the ressoner server
>> end-point URL.}
>> +        * @Param input_graph {A string contains the IRI of RDF (either
>> RDF/XML or
>> +        *        OWL) to be classified.}
>> +        * @Param owllink_endpoint {A string contains the ressoner server
>> end-point
>> +        *        URL.}
>>       * @return Return: <br/>
>>       *          200 The ontology is retrieved, containing only class
>>       axioms <br/>
>>       *          400 To run the session is needed the scope <br/>
>> @@ -144,8 +209,15 @@ public class Classify {
>>       */
>>      @POST
>>      @Consumes(MediaType.MULTIPART_FORM_DATA)
>> -
>> @Produces(value={KReSFormat.RDF_XML,KReSFormat.TURTLE,KReSFormat.OWL_XML})
>> -    public Response ontologyClassify(@FormParam(value="session") String
>> session,@FormParam(value="scope") String scope,@FormParam(value="recipe")
>> String recipe,@FormParam(value="input-graph") String
>> input_graph,@FormParam(value="file") File
>> file,@FormParam(value="owllink-endpoint") String owllink_endpoint){
>> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> +                       KReSFormat.OWL_XML })
>> +       public Response ontologyClassify(
>> +                       @FormParam(value = "session") String session,
>> +                       @FormParam(value = "scope") String scope,
>> +                       @FormParam(value = "recipe") String recipe,
>> +                       @FormParam(value = "input-graph") String
>> input_graph,
>> +                       @FormParam(value = "file") File file,
>> +                       @FormParam(value = "owllink-endpoint") String
>> owllink_endpoint) {
>>
>>        try{
>>
>> @@ -162,22 +234,28 @@ public class Classify {
>>
>>        //Load input file or graph
>>        if(file!=null)
>> -        this.inputowl =
>> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(file);
>> +                               this.inputowl =
>> OWLManager.createOWLOntologyManager()
>> +
>> .loadOntologyFromOntologyDocument(file);
>>        if(input_graph!=null)
>> -        this.inputowl =
>> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(input_graph));
>> +                               this.inputowl =
>> OWLManager.createOWLOntologyManager()
>> +
>> .loadOntologyFromOntologyDocument(
>> +
>> IRI.create(input_graph));
>>        if(inputowl==null&&(session==null||scope==null))
>>          return Response.status(Status.NOT_FOUND).build();
>>        if(inputowl==null){
>>            if(scope!=null)
>> -            this.inputowl =
>> OWLManager.createOWLOntologyManager().createOntology();
>> +                                       this.inputowl =
>> OWLManager.createOWLOntologyManager()
>> +
>> .createOntology();
>>            else{
>> -            this.inputowl =
>> OWLManager.createOWLOntologyManager().createOntology();
>> +                                       this.inputowl =
>> OWLManager.createOWLOntologyManager()
>> +
>> .createOntology();
>>            }
>>        }
>>
>>         //Create list to add ontologies as imported
>>         OWLOntologyManager mgr = inputowl.getOWLOntologyManager();
>> -       OWLDataFactory factory =
>> inputowl.getOWLOntologyManager().getOWLDataFactory();
>> +                       OWLDataFactory factory =
>> inputowl.getOWLOntologyManager()
>> +                                       .getOWLDataFactory();
>>         List<OWLOntologyChange> additions = new
>>         LinkedList<OWLOntologyChange>();
>>
>>         boolean ok = false;
>> @@ -187,16 +265,22 @@ public class Classify {
>>        if((scope!=null)&&(session==null))
>>        try{
>>            IRI iri = IRI.create(scope);
>> -          ScopeRegistry reg = ONManager.get().getScopeRegistry();
>> +                                       ScopeRegistry reg =
>> onm.getScopeRegistry();
>>            OntologyScope ontoscope = reg.getScope(iri);
>> -          Iterator<OWLOntology> importscope =
>> ontoscope.getCustomSpace().getOntologies().iterator();
>> -          Iterator<OntologySpace> importsession =
>> ontoscope.getSessionSpaces().iterator();
>> +                                       Iterator<OWLOntology> importscope
>> = ontoscope
>> +
>> .getCustomSpace().getOntologies().iterator();
>> +                                       Iterator<OntologySpace>
>> importsession = ontoscope
>> +
>> .getSessionSpaces().iterator();
>>
>> -          //Add ontology as import form scope, if it is anonymus we try
>> to add single axioms.
>> +                                       // Add ontology as import form
>> scope, if it is anonymus we
>> +                                       // try to add single axioms.
>>            while(importscope.hasNext()){
>>              OWLOntology auxonto = importscope.next();
>>              if(!auxonto.getOntologyID().isAnonymous()){
>> -            additions.add(new AddImport(inputowl,
>> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                                       additions.add(new
>> AddImport(inputowl, factory
>> +
>> .getOWLImportsDeclaration(auxonto
>> +
>>               .getOWLOntologyManager()
>> +
>>               .getOntologyDocumentIRI(auxonto))));
>>              }else{
>>                  mgr.addAxioms(inputowl,auxonto.getAxioms());
>>              }
>> @@ -204,11 +288,19 @@ public class Classify {
>>
>>           //Add ontology form sessions
>>           while(importsession.hasNext()){
>> -             Iterator<OWLOntology> sessionontos =
>> importsession.next().getOntologies().iterator();
>> +                                               Iterator<OWLOntology>
>> sessionontos = importsession
>> +
>> .next().getOntologies().iterator();
>>               while(sessionontos.hasNext()){
>>                  OWLOntology auxonto = sessionontos.next();
>>                  if(!auxonto.getOntologyID().isAnonymous()){
>> -                    additions.add(new AddImport(inputowl,
>> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                                               additions
>> +
>>       .add(new AddImport(
>> +
>>                       inputowl,
>> +
>>                       factory
>> +
>>                                       .getOWLImportsDeclaration(auxonto
>> +
>>
>> .getOWLOntologyManager()
>> +
>>
>> .getOntologyDocumentIRI(
>> +
>>
>> auxonto))));
>>                  }else{
>>                      mgr.addAxioms(inputowl,auxonto.getAxioms());
>>                  }
>> @@ -226,30 +318,38 @@ public class Classify {
>>        if((session!=null)&&(scope!=null))
>>        try{
>>            IRI iri = IRI.create(scope);
>> -          ScopeRegistry reg = ONManager.get().getScopeRegistry();
>> +                                       ScopeRegistry reg =
>> onm.getScopeRegistry();
>>            OntologyScope ontoscope = reg.getScope(iri);
>> -          SessionOntologySpace sos =
>> ontoscope.getSessionSpace(IRI.create(session));
>> +                                       SessionOntologySpace sos =
>> ontoscope.getSessionSpace(IRI
>> +
>> .create(session));
>>
>> -          Set<OWLOntology> ontos =
>> sos.getOntologyManager().getOntologies();
>> +                                       Set<OWLOntology> ontos =
>> sos.getOntologyManager()
>> +                                                       .getOntologies();
>>            Iterator<OWLOntology> iteronto = ontos.iterator();
>>
>> -          //Add session ontologies as import, if it is anonymus we try
>> to add single axioms.
>> +                                       // Add session ontologies as
>> import, if it is anonymus we
>> +                                       // try to add single axioms.
>>            while(iteronto.hasNext()){
>>              OWLOntology auxonto = iteronto.next();
>>              if(!auxonto.getOntologyID().isAnonymous()){
>> -                additions.add(new AddImport(inputowl,
>> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> +                                                       additions.add(new
>> AddImport(inputowl, factory
>> +
>> .getOWLImportsDeclaration(auxonto
>> +
>>               .getOWLOntologyManager()
>> +
>>               .getOntologyDocumentIRI(auxonto))));
>>              }else{
>>                  mgr.addAxioms(inputowl,auxonto.getAxioms());
>>              }
>>            }
>>
>>        }catch(Exception e){
>> -          System.err.println("ERROR: Problem with session: "+session);
>> +                                       System.err.println("ERROR:
>> Problem with session: "
>> +                                                       + session);
>>            e.printStackTrace();
>>            Response.status(Status.NOT_FOUND).build();
>>        }
>>
>> -      //After gathered the all ontology as imported now we apply the
>> changes
>> +                       // After gathered the all ontology as imported
>> now we apply the
>> +                       // changes
>>        if(additions.size()>0)
>>          mgr.applyChanges(additions);
>>
>> @@ -258,23 +358,35 @@ public class Classify {
>>
>>         try{
>>         if(recipe!=null) {
>> -            OWLOntology recipeowl =
>> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(recipe));
>> -            //Get Jea RDF model of SWRL rule contained in the recipe
>> +                                               OWLOntology recipeowl =
>> OWLManager
>> +
>> .createOWLOntologyManager()
>> +
>> .loadOntologyFromOntologyDocument(
>> +
>>       IRI.create(recipe));
>> +                                               // Get Jea RDF model of
>> SWRL rule contained in the
>> +                                               // recipe
>>              Model swrlmodel = fromRecipeToModel(recipeowl);
>>
>> -            //Create a reasoner to run rules contained in the recipe
>> -            KReSRunRules rulereasoner = new
>> KReSRunRules(swrlmodel,inputowl);
>> -            //Run the rule reasoner to the input RDF with the added
>> top-ontology
>> +                                               // Create a reasoner to
>> run rules contained in the
>> +                                               // recipe
>> +                                               KReSRunRules rulereasoner
>> = new KReSRunRules(swrlmodel,
>> +
>> inputowl);
>> +                                               // Run the rule reasoner
>> to the input RDF with the added
>> +                                               // top-ontology
>>              inputowl = rulereasoner.runRulesReasoner();
>>         }
>>
>>              //Create the reasoner for the classification
>> -            KReSCreateReasoner newreasoner = new
>> KReSCreateReasoner(inputowl);
>> -            //Prepare and start the reasoner to classify ontology's
>> resources
>> -            KReSRunReasoner reasoner = new
>> KReSRunReasoner(newreasoner.getReasoner());
>> -
>> -            //Create a new OWLOntology model where to put the inferred
>> axioms
>> -            OWLOntology output =
>> OWLManager.createOWLOntologyManager().createOntology(inputowl.getOntologyID());
>> +                                       KReSCreateReasoner newreasoner =
>> new KReSCreateReasoner(
>> +                                                       inputowl);
>> +                                       // Prepare and start the reasoner
>> to classify ontology's
>> +                                       // resources
>> +                                       KReSRunReasoner reasoner = new
>> KReSRunReasoner(newreasoner
>> +                                                       .getReasoner());
>> +
>> +                                       // Create a new OWLOntology model
>> where to put the inferred
>> +                                       // axioms
>> +                                       OWLOntology output =
>> OWLManager.createOWLOntologyManager()
>> +
>> .createOntology(inputowl.getOntologyID());
>>              //Initial input axioms count
>>              int startax = output.getAxiomCount();
>>              //Run the classification
>> @@ -295,26 +407,40 @@ public class Classify {
>>             return Response.status(Status.NOT_FOUND).build();
>>          }
>>
>> -      //If there is an owl-link server end-point specified in the form
>> +                               // If there is an owl-link server
>> end-point specified in the
>> +                               // form
>>        }else{
>>
>>        try{
>>         if(recipe!=null) {
>> -         OWLOntology recipeowl =
>> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(recipe));
>> -         //Get Jea RDF model of SWRL rule contained in the recipe
>> +                                               OWLOntology recipeowl =
>> OWLManager
>> +
>> .createOWLOntologyManager()
>> +
>> .loadOntologyFromOntologyDocument(
>> +
>>       IRI.create(recipe));
>> +                                               // Get Jea RDF model of
>> SWRL rule contained in the
>> +                                               // recipe
>>           Model swrlmodel = fromRecipeToModel(recipeowl);
>> -         //Create a reasoner to run rules contained in the recipe by
>> using the server and-point
>> -         KReSRunRules rulereasoner = new
>> KReSRunRules(swrlmodel,inputowl,new URL(owllink_endpoint));
>> -         //Run the rule reasoner to the input RDF with the added
>> top-ontology
>> +                                               // Create a reasoner to
>> run rules contained in the
>> +                                               // recipe by using the
>> server and-point
>> +                                               KReSRunRules rulereasoner
>> = new KReSRunRules(swrlmodel,
>> +                                                               inputowl,
>> new URL(owllink_endpoint));
>> +                                               // Run the rule reasoner
>> to the input RDF with the added
>> +                                               // top-ontology
>>           inputowl = rulereasoner.runRulesReasoner();
>>         }
>> -         //Create the reasoner for the consistency check by using the
>> server and-point
>> -         KReSCreateReasoner newreasoner = new
>> KReSCreateReasoner(inputowl, new URL(owllink_endpoint));
>> -         //Prepare and start the reasoner to classify ontology's
>> resources
>> -         KReSRunReasoner reasoner = new
>> KReSRunReasoner(newreasoner.getReasoner());
>> -
>> -         //Create a new OWLOntology model where to put the inferred
>> axioms
>> -         OWLOntology output =
>> OWLManager.createOWLOntologyManager().createOntology(inputowl.getOntologyID());
>> +                                       // Create the reasoner for the
>> consistency check by using
>> +                                       // the server and-point
>> +                                       KReSCreateReasoner newreasoner =
>> new KReSCreateReasoner(
>> +                                                       inputowl, new
>> URL(owllink_endpoint));
>> +                                       // Prepare and start the reasoner
>> to classify ontology's
>> +                                       // resources
>> +                                       KReSRunReasoner reasoner = new
>> KReSRunReasoner(newreasoner
>> +                                                       .getReasoner());
>> +
>> +                                       // Create a new OWLOntology model
>> where to put the inferred
>> +                                       // axioms
>> +                                       OWLOntology output =
>> OWLManager.createOWLOntologyManager()
>> +
>> .createOntology(inputowl.getOntologyID());
>>           //Initial input axioms count
>>           int startax = output.getAxiomCount();
>>           //Run the classification
>>
>> Modified:
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
>> URL:
>> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> ==============================================================================
>> ---
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
>> (original)
>> +++
>> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
>> Wed Dec 29 18:04:19 2010
>> @@ -2,6 +2,7 @@ package eu.iksproject.kres.jersey.reason
>>
>>  import java.io.File;
>>  import java.net.URL;
>> +import java.util.Hashtable;
>>  import java.util.Iterator;
>>  import java.util.LinkedList;
>>  import java.util.List;
>> @@ -14,7 +15,6 @@ import javax.ws.rs.GET;
>>  import javax.ws.rs.POST;
>>  import javax.ws.rs.Path;
>>  import javax.ws.rs.PathParam;
>> -import javax.ws.rs.Produces;
>>  import javax.ws.rs.WebApplicationException;
>>  import javax.ws.rs.core.Context;
>>  import javax.ws.rs.core.MediaType;
>> @@ -44,6 +44,7 @@ import com.hp.hpl.jena.rdf.model.Model;
>>  import com.hp.hpl.jena.rdf.model.ModelFactory;
>>  import com.hp.hpl.jena.rdf.model.Resource;
>>
>> +import eu.iksproject.kres.api.manager.KReSONManager;
>>  import eu.iksproject.kres.api.manager.OWLDuplicateSafeLoader;
>>  import eu.iksproject.kres.api.manager.ontology.OntologyScope;
>>  import eu.iksproject.kres.api.manager.ontology.OntologySpace;
>> @@ -53,6 +54,7 @@ import eu.iksproject.kres.api.rules.KReS
>>  import eu.iksproject.kres.api.rules.NoSuchRecipeException;
>>  import eu.iksproject.kres.api.rules.RuleStore;
>>  import eu.iksproject.kres.api.rules.util.KReSRuleList;
>> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>>  import eu.iksproject.kres.manager.ONManager;
>>  import eu.iksproject.kres.reasoners.KReSCreateReasoner;
>>  import eu.iksproject.kres.reasoners.KReSRunReasoner;
>> @@ -60,6 +62,7 @@ import eu.iksproject.kres.reasoners.KReS
>>  import eu.iksproject.kres.rules.KReSKB;
>>  import eu.iksproject.kres.rules.manager.KReSRuleStore;
>>  import eu.iksproject.kres.rules.parser.KReSRuleParser;
>> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>>
>>  /**
>>   * This class implements the REST interface for the /check-consistency
>>   service
>> @@ -75,7 +78,10 @@ public class ConsistencyCheck {
>>       private OWLOntology scopeowl;
>>
>>       private final OWLDuplicateSafeLoader loader = new OWLDuplicateSafeLoader();
>> -       private final Logger log = LoggerFactory.getLogger(getClass());
>> +       protected KReSONManager onm;
>> +       protected OntologyStoreProvider storeProvider;
>> +
>> +       private Logger log = LoggerFactory.getLogger(getClass());
>>
>>       /**
>>        * The constructor.
>> @@ -85,24 +91,40 @@ public class ConsistencyCheck {
>>        */
>>       public ConsistencyCheck(@Context ServletContext servletContext) {
>>
>> -               /**
>> -                * Retrieve the rule store
>> -                */
>> +               // Retrieve the rule store
>>               this.kresRuleStore = (RuleStore) servletContext
>>                               .getAttribute(RuleStore.class.getName());
>> -               /**
>> +               // Retrieve the ontology network manager
>> +               this.onm = (KReSONManager) servletContext
>> +
>> .getAttribute(KReSONManager.class.getName());
>> +               this.storeProvider = (OntologyStoreProvider)
>> servletContext
>> +
>> .getAttribute(OntologyStoreProvider.class.getName());
>> +               // Contingency code for missing components follows.
>> +               /*
>>                * FIXME! The following code is required only for the tests. This should
>>                * be removed and the test should work without this code.
>>                */
>> +               if (storeProvider == null) {
>> +                       log
>> +                                       .warn("No OntologyStoreProvider
>> in servlet context. Instantiating manually...");
>> +                       storeProvider = new
>> OntologyStorageProviderImpl();
>> +               }
>> +               if (onm == null) {
>> +                       log
>> +                                       .warn("No KReSONManager in
>> servlet context. Instantiating manually...");
>> +                       onm = new
>> ONManager(storeProvider.getActiveOntologyStorage(),
>> +                                       new Hashtable<String, Object>());
>> +               }
>>               if (kresRuleStore == null) {
>>                       log
>> -                                       .warn(
>> -                                                       "KReSRuleStore
>> with stored rules and recipes is missing in ServletContext. A new
>> instance has been created.",
>> -                                                       this);
>> -                       this.kresRuleStore = new KReSRuleStore("");
>> -                       log.info("Configuration file loaded from: "
>> +                                       .warn("No KReSRuleStore with
>> stored rules and recipes found in servlet context. Instantiating manually
>> with default values...");
>> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> +                                       new Hashtable<String, Object>(),
>> "");
>> +                       log
>> +                                       .debug("PATH TO OWL FILE LOADED:
>> "
>>                                       + kresRuleStore.getFilePath());
>>               }
>> +
>>       }
>>
>>       /**
>> @@ -115,7 +137,9 @@ public class ConsistencyCheck {
>>       private Model fromRecipeToModel(OWLOntology owl)
>>                       throws NoSuchRecipeException, OWLOntologyCreationException {
>>
>> -               RuleStore store = new KReSRuleStore(owl);
>> +               // FIXME: why the heck is this method re-instantiating a
>> rule store?!?
>> +               RuleStore store = new KReSRuleStore(onm,
>> +                               new Hashtable<String, Object>(), owl);
>>               Model jenamodel = ModelFactory.createDefaultModel();
>>
>>               OWLDataFactory factory = owl.getOWLOntologyManager()
>> @@ -199,7 +223,10 @@ public class ConsistencyCheck {
>>                               log.debug("Some ontology import failed. Cannot continue.", uu);
>>                               return Response.status(Status.PRECONDITION_FAILED).build();
>>                       } catch (Exception ee) {
>> -                               log.error("Cannot fetch the ontology.
>> Some error occurred. Cannot continue.", ee);
>> +                               log
>> +                                               .error(
>> +                                                               "Cannot
>> fetch the ontology. Some error occurred. Cannot continue.",
>> +                                                               ee);
>>                               return Response.status(Status.NOT_FOUND).build();
>>                       }
>>                       KReSCreateReasoner newreasoner = new KReSCreateReasoner(owl);
>> @@ -312,7 +339,7 @@ public class ConsistencyCheck {
>>                       if ((scope != null) && (session == null))
>>                               try {
>>                                       IRI iri = IRI.create(scope);
>> -                                       ScopeRegistry reg =
>> ONManager.get().getScopeRegistry();
>> +                                       ScopeRegistry reg =
>> onm.getScopeRegistry();
>>                                       OntologyScope ontoscope = reg.getScope(iri);
>>                                       Iterator<OWLOntology> importscope = ontoscope
>>                                                       .getCustomSpace().getOntologies().iterator();
>> @@ -365,7 +392,7 @@ public class ConsistencyCheck {
>>                       if ((session != null) && (scope != null))
>>                               try {
>>                                       IRI iri = IRI.create(scope);
>> -                                       ScopeRegistry reg =
>> ONManager.get().getScopeRegistry();
>> +                                       ScopeRegistry reg =
>> onm.getScopeRegistry();
>>                                       OntologyScope ontoscope = reg.getScope(iri);
>>                                       SessionOntologySpace sos = ontoscope.getSessionSpace(IRI
>>                                                       .create(session));
>>
>>
>>
>



-- 
Enrico Daga
Technology Expert
--
Ufficio Sistemi Informativi  (DCSPI-USI)
National Research Council (CNR)
P.le Aldo Moro 7 - Rome, Italy
Tel +39 4993 3321
--
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC-CNR)
Via Nomentana 56, Rome - Italy
--
http://stlab.istc.cnr.it/stlab/User:EnricoDaga
http://www.enridaga.net
skype: enri-pan

Re: svn commit: r1053689 [1/6] - in /incubator/stanbol/trunk/kres: eu.iksproject.kres.api/ eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/ eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/ eu.

Posted by Enrico Daga <en...@gmail.com>.
You have been clear. I want just to mention that line ending changes
have been necessary in the patch and not in the code that was already
in the SVN. In this case was impossible to divide the two operations
since I needed to clean the patch before make it acceptable by the
apache SVN, which do not allow mixed line ending.
Probably my comment to the commit was not enough clear, I will try to
make clearer comments in the future.

Thank you

Enrico

On 29 December 2010 22:42, Upayavira <uv...@odoko.co.uk> wrote:
> I'm not objecting to anything in the commits per se, just saying, if you
> need to do line endings, etc, do them as a commit that is *just* line
> endings, and then another commit containing substantial changes.
>
> That assists others in tracking changes - they can review the changes
> you made as a result of STANBOL-10 as a hopefully small commit message.
>
> Separating these changes into two commits just leaves a much clearer
> audit trail behind.
>
> Clearer?
>
> Thanks, Upayavira
>
> On Wed, 29 Dec 2010 19:20 +0100, "Enrico Daga" <en...@gmail.com>
> wrote:
>> The tidying was needed, elsewhere the patch posted in STANBOL-10 would
>> not be accepted by SVN.
>> This is why I did the conversion of line endings.
>> The changes have been commented in the related issue.
>>
>> Please tell me if I misunderstood something.
>> Enrico
>>
>> On 29 December 2010 19:12, Upayavira <uv...@odoko.co.uk> wrote:
>> > Please keep 'code tidying' commits and actual code change commits
>> > separate, otherwise it can be difficult to review the changes - e.g.
>> > what of this commit is actual change?
>> >
>> > Thanks,
>> >
>> > Upaayvira
>> >
>> >
>> > On Wed, 29 Dec 2010 18:04 +0000, enridaga@apache.org wrote:
>> >> Author: enridaga
>> >> Date: Wed Dec 29 18:04:19 2010
>> >> New Revision: 1053689
>> >>
>> >> URL: http://svn.apache.org/viewvc?rev=1053689&view=rev
>> >> Log:
>> >> STANBOL-10
>> >> Applying patch posted by Alessandro Adamou.
>> >> Before that, applied a conversion for consistent line ending.
>> >>
>> >> Added:
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/resources/META-INF/conf/catalog.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/KReSConf/
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/KReSConf/rmi_config.owl
>> >> Modified:
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Enrichment.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMOntResource.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMRootResource.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMScopeOntologyResource.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMScopeResource.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/Activator.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ONManager.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/io/OntologyRegistryIRISource.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/AbstractOntologySpaceImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/CoreOntologySpaceImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/CustomOntologySpaceImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyIndexImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyScopeFactoryImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyScopeImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologySpaceFactoryImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/SessionOntologySpaceImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/registry/model/impl/RegistryLoader.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/session/KReSSessionManagerImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/session/ScopeSessionSynchronizer.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/util/OntologyUtils.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/org/stlab/xd/utils/RDFSLabelGetter.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/Namespace.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestIndexing.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestOntologyScope.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestOntologySpaces.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/registry/TestRegistry.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/session/TestSessions.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.ontologies/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.reasoners/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.reasoners/src/main/java/eu/iksproject/kres/reasoners/KReSReasonerImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSAddRecipe.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSRuleStore.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSSetRuleStore.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/resources/RuleOntology/rmi_config.owl
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSAddRecipeTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSAddRuleTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSGetRecipeTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSGetRuleTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSLoadRuleFileTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRemoveRecipeTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRemoveRuleTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRuleStoreTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.manager/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.manager/src/main/java/eu/iksproject/kres/semion/manager/SemionManagerImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/test/java/eu/iksproject/kres/semion/reengineer/db/DBExtractorTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/test/java/eu/iksproject/kres/semion/reengineer/xml/XMLReengineerTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/hermit124/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/mysql/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/owlapi3/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/owllink102/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/xerces/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/transformation/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage.provider/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage.provider/src/main/java/eu/iksproject/kres/storage/provider/OntologyStorageProviderImpl.java
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage/pom.xml
>> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage/src/main/java/eu/iksproject/kres/storage/ClerezzaStorage.java
>> >>
>> >> Modified: incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml?rev=1053689&r1=1053688&r2=1053689&view=diff
>> >> ==============================================================================
>> >> --- incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
>> >> (original)
>> >> +++ incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml Wed Dec
>> >> 29 18:04:19 2010
>> >> @@ -7,14 +7,14 @@
>> >>       <parent>
>> >>               <groupId>eu.iksproject</groupId>
>> >>               <artifactId>eu.iksproject.kres.parent</artifactId>
>> >> -               <version>0.6-SNAPSHOT</version>
>> >> +               <version>0.7</version>
>> >>               <relativePath>../parent/pom.xml</relativePath>
>> >>       </parent>
>> >>
>> >>       <groupId>eu.iksproject</groupId>
>> >>       <artifactId>eu.iksproject.kres.api</artifactId>
>> >>       <packaging>bundle</packaging>
>> >> -       <version>0.6-SNAPSHOT</version>
>> >> +       <version>${kres-version}</version>
>> >>
>> >>       <name>IKS KReS API</name>
>> >>       <description>KReS API</description>
>> >> @@ -23,7 +23,7 @@
>> >>
>> >>       <properties>
>> >>               <jersey-version>1.1.5.1</jersey-version>
>> >> -               <kres-version>0.6-SNAPSHOT</kres-version>
>> >> +               <kres-version>0.7</kres-version>
>> >>               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >>       </properties>
>> >>
>> >> @@ -36,7 +36,7 @@
>> >>                               <configuration>
>> >>                                       <instructions>
>> >>                                               <Export-Package>
>> >> -
>> >> eu.iksproject.kres.api.*;version=${pom.version},
>> >> +
>> >> eu.iksproject.kres.api.*;version=${kres-version},
>> >>                                                       com.hp.hpl.jena.*,
>> >>                                                       com.ibm.icu.*,
>> >>                                                       com.sun.jersey.*,
>> >>
>> >> Added:
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java?rev=1053689&view=auto
>> >> ==============================================================================
>> >> ---
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> >> (added)
>> >> +++
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
>> >> Wed Dec 29 18:04:19 2010
>> >> @@ -0,0 +1,17 @@
>> >> +package eu.iksproject.kres.api.manager.ontology;
>> >> +
>> >> +public enum SpaceType {
>> >> +
>> >> +       CORE("core"), CUSTOM("custom"), SESSION("session");
>> >> +
>> >> +       private SpaceType(String suffix) {
>> >> +               this.suffix = suffix;
>> >> +       }
>> >> +
>> >> +       private String suffix;
>> >> +
>> >> +       public String getIRISuffix() {
>> >> +               return suffix;
>> >> +       }
>> >> +
>> >> +}
>> >>
>> >> Modified:
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> >> ==============================================================================
>> >> ---
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> >> (original)
>> >> +++
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
>> >> Wed Dec 29 18:04:19 2010
>> >> @@ -26,7 +26,7 @@ public interface KReSRegistryLoader {
>> >>
>> >>       public boolean hasLibrary(Registry reg, IRI libraryID);
>> >>
>> >> -       public boolean isPrintingLoadedOntologies();
>> >> +//     public boolean isPrintingLoadedOntologies();
>> >>
>> >>       public void loadLocations() throws RegistryContentException;
>> >>
>> >> @@ -40,5 +40,5 @@ public interface KReSRegistryLoader {
>> >>        */
>> >>       public Set<Registry> loadRegistriesEager(IRI physicalIRI);
>> >>
>> >> -       public void setPrintLoadedOntologies(boolean doPrint);
>> >> +//     public void setPrintLoadedOntologies(boolean doPrint);
>> >>  }
>> >>
>> >> Added:
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl?rev=1053689&view=auto
>> >> ==============================================================================
>> >> ---
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> >> (added)
>> >> +++
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
>> >> Wed Dec 29 18:04:19 2010
>> >> @@ -0,0 +1,174 @@
>> >> +<?xml version="1.0"?>
>> >> +<rdf:RDF
>> >> xmlns="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#"
>> >> +     xml:base="http://kres.iks-project.eu/ontology/meta/rmi_config.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_config.owl">
>> >> +        <owl:imports
>> >> rdf:resource="http://ontologydesignpatterns.org/ont/iks/kres/rmi.owl"/>
>> >> +    </owl:Ontology>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +    //
>> >> +    // Object Properties
>> >> +    //
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +     -->
>> >> +
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith -->
>> >> +
>> >> +    <owl:ObjectProperty
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule -->
>> >> +
>> >> +    <owl:ObjectProperty
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith -->
>> >> +
>> >> +    <owl:ObjectProperty
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes
>> >> -->
>> >> +
>> >> +    <owl:ObjectProperty
>> >> rdf:about="http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +    //
>> >> +    // Data properties
>> >> +    //
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +     -->
>> >> +
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead
>> >> -->
>> >> +
>> >> +    <owl:DatatypeProperty
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription
>> >> -->
>> >> +
>> >> +    <owl:DatatypeProperty
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence
>> >> -->
>> >> +
>> >> +    <owl:DatatypeProperty
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +    //
>> >> +    // Classes
>> >> +    //
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +     -->
>> >> +
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule -->
>> >> +
>> >> +    <owl:Class
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe -->
>> >> +
>> >> +    <owl:Class
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +    //
>> >> +    // Individuals
>> >> +    //
>> >> +
>> >> ///////////////////////////////////////////////////////////////////////////////////////
>> >> +     -->
>> >> +
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA -->
>> >> +
>> >> +    <owl:NamedIndividual
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA">
>> >> +        <rdf:type
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
>> >> +        <rmi:hasDescription
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Some description
>> >> here</rmi:hasDescription>
>> >> +        <rmi:hasSequence
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://eu.iksproject.kres/KReSOntologyRules.owl#MyRuleB,http://eu.iksproject.kres/KReSOntologyRules.owl#MyRuleA</rmi:hasSequence>
>> >> +        <rmi:hasRule
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
>> >> +        <rmi:endWith
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
>> >> +        <rmi:hasRule
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB"/>
>> >> +        <rmi:startWith
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB"/>
>> >> +    </owl:NamedIndividual>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA
>> >> -->
>> >> +
>> >> +    <owl:NamedIndividual
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA">
>> >> +        <rdf:type
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> >> +        <rmi:hasDescription
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example of
>> >> description for my rule A</rmi:hasDescription>
>> >> +        <rmi:hasBodyAndHead
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BodyA -&gt;
>> >> BodyB</rmi:hasBodyAndHead>
>> >> +    </owl:NamedIndividual>
>> >> +
>> >> +
>> >> +
>> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB
>> >> -->
>> >> +
>> >> +    <owl:NamedIndividual
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB">
>> >> +        <rdf:type
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> >> +        <rmi:hasDescription
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example of
>> >> description..for my rule B</rmi:hasDescription>
>> >> +        <rmi:hasBodyAndHead
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BodyB -&gt;
>> >> HeadB</rmi:hasBodyAndHead>
>> >> +        <sequence:directlyPrecedes
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
>> >> +    </owl:NamedIndividual>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRecipe
>> >> -->
>> >> +
>> >> +    <owl:NamedIndividual
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRecipe">
>> >> +        <rdf:type
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
>> >> +        <rmi:hasDescription
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A single rule
>> >> recipe.</rmi:hasDescription>
>> >> +        <rmi:hasSequence
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule</rmi:hasSequence>
>> >> +        <rmi:endWith
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
>> >> +        <rmi:hasRule
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
>> >> +        <rmi:startWith
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
>> >> +    </owl:NamedIndividual>
>> >> +
>> >> +
>> >> +
>> >> +    <!--
>> >> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule
>> >> -->
>> >> +
>> >> +    <owl:NamedIndividual
>> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule">
>> >> +        <rdf:type
>> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
>> >> +        <rmi:hasDescription
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A rule to
>> >> inference if a person has an uncle.</rmi:hasDescription>
>> >> +        <rmi:hasBodyAndHead
>> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ProvaParent =
>> >> &lt;http://www.semanticweb.org/ontologies/2010/6/ProvaParent.owl#&gt; .
>> >> rule1[ has(ProvaParent:hasParent, ?x, ?y) . has(ProvaParent:hasBrother,
>> >> ?y, ?z) -&gt; has(ProvaParent:hasUncle, ?x, ?z) ]</rmi:hasBodyAndHead>
>> >> +    </owl:NamedIndividual>
>> >> +</rdf:RDF>
>> >> +
>> >> +
>> >> +
>> >> +<!-- Generated by the OWL API (version 3.0.0.1413)
>> >> http://owlapi.sourceforge.net -->
>> >> +
>> >>
>> >> Modified: incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml?rev=1053689&r1=1053688&r2=1053689&view=diff
>> >> ==============================================================================
>> >> --- incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
>> >> (original)
>> >> +++ incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml Wed
>> >> Dec 29 18:04:19 2010
>> >> @@ -7,13 +7,13 @@
>> >>       <parent>
>> >>               <groupId>eu.iksproject</groupId>
>> >>               <artifactId>eu.iksproject.kres.parent</artifactId>
>> >> -               <version>0.6-SNAPSHOT</version>
>> >> +               <version>0.7</version>
>> >>               <relativePath>../parent/pom.xml</relativePath>
>> >>       </parent>
>> >>
>> >>       <groupId>eu.iksproject</groupId>
>> >>       <artifactId>eu.iksproject.kres.jersey</artifactId>
>> >> -       <version>0.6-SNAPSHOT</version>
>> >> +       <version>${kres-version}</version>
>> >>       <packaging>bundle</packaging>
>> >>
>> >>       <name>IKS KReS Jersey JAX-RS API and front-end</name>
>> >> @@ -22,7 +22,8 @@
>> >>       <properties>
>> >>               <jersey-version>1.1.5.1</jersey-version>
>> >>               <pax-exam-version>1.2.0</pax-exam-version>
>> >> -               <kres-version>0.6-SNAPSHOT</kres-version>
>> >> +               <kres-version>0.7</kres-version>
>> >> +
>> >> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>> >>       </properties>
>> >>
>> >>       <dependencies>
>> >> @@ -252,6 +253,12 @@
>> >>              <scope>provided</scope>
>> >>           </dependency>
>> >>               <dependency>
>> >> +                       <groupId>eu.iksproject</groupId>
>> >> +
>> >> <artifactId>eu.iksproject.kres.storage.provider</artifactId>
>> >> +                       <version>${kres-version}</version>
>> >> +                       <scope>provided</scope>
>> >> +               </dependency>
>> >> +               <dependency>
>> >>                       <groupId>com.hp.hpl.jena</groupId>
>> >>                       <artifactId>jena</artifactId>
>> >>                       <version>2.6.2</version>
>> >>
>> >> Modified:
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> >> ==============================================================================
>> >> ---
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> >> (original)
>> >> +++
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
>> >> Wed Dec 29 18:04:19 2010
>> >> @@ -5,19 +5,14 @@
>> >>
>> >>  package eu.iksproject.kres.jersey.manager;
>> >>
>> >> -import eu.iksproject.kres.api.rules.RuleStore;
>> >> -import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> >> -import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> >> -import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> >> -import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> >> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> >> -import eu.iksproject.kres.api.format.KReSFormat;
>> >>  import java.util.HashMap;
>> >> +import java.util.Hashtable;
>> >>  import java.util.Iterator;
>> >>  import java.util.LinkedList;
>> >>  import java.util.List;
>> >>  import java.util.Set;
>> >>  import java.util.Vector;
>> >> +
>> >>  import javax.servlet.ServletContext;
>> >>  import javax.ws.rs.Consumes;
>> >>  import javax.ws.rs.DELETE;
>> >> @@ -33,8 +28,8 @@ import javax.ws.rs.core.Context;
>> >>  import javax.ws.rs.core.MediaType;
>> >>  import javax.ws.rs.core.Response;
>> >>  import javax.ws.rs.core.Response.Status;
>> >> +
>> >>  import org.semanticweb.owlapi.apibinding.OWLManager;
>> >> -import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
>> >>  import org.semanticweb.owlapi.model.AddImport;
>> >>  import org.semanticweb.owlapi.model.IRI;
>> >>  import org.semanticweb.owlapi.model.OWLDataFactory;
>> >> @@ -45,59 +40,102 @@ import org.semanticweb.owlapi.model.OWLO
>> >>  import org.semanticweb.owlapi.model.OWLOntology;
>> >>  import org.semanticweb.owlapi.model.OWLOntologyChange;
>> >>  import org.semanticweb.owlapi.model.OWLOntologyStorageException;
>> >> +import org.slf4j.Logger;
>> >> +import org.slf4j.LoggerFactory;
>> >>
>> >> -import com.sun.jersey.api.view.ImplicitProduces;
>> >> +import eu.iksproject.kres.api.format.KReSFormat;
>> >> +import eu.iksproject.kres.api.manager.KReSONManager;
>> >> +import eu.iksproject.kres.api.rules.RuleStore;
>> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>> >> +import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> >> +import eu.iksproject.kres.manager.ONManager;
>> >> +import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> >> +import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> >> +import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> >> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>> >>
>> >>  /**
>> >>   *
>> >>   * @author elvio
>> >>   */
>> >> -@Path("/recipe")///{uri:.+}")
>> >> +@Path("/recipe")
>> >> +// /{uri:.+}")
>> >>  //@ImplicitProduces(MediaType.TEXT_HTML + ";qs=2")
>> >>  public class Recipe extends NavigationMixin{
>> >>
>> >> +       protected KReSONManager onm;
>> >> +
>> >> +       private Logger log = LoggerFactory.getLogger(getClass());
>> >> +
>> >>      private RuleStore kresRuleStore;
>> >> +       private OntologyStoreProvider storeProvider;
>> >>
>> >>     /**
>> >>       * To get the KReSRuleStore where are stored the rules and the
>> >>       recipes
>> >>       *
>> >> -     * @param servletContext {To get the context where the REST service
>> >> is running.}
>> >> +        * @param servletContext
>> >> +        *            {To get the context where the REST service is
>> >> running.}
>> >>       */
>> >>      public Recipe(@Context ServletContext servletContext){
>> >> -       this.kresRuleStore = (RuleStore)
>> >> servletContext.getAttribute(RuleStore.class.getName());
>> >> +               this.kresRuleStore = (RuleStore) servletContext
>> >> +                               .getAttribute(RuleStore.class.getName());
>> >> +               this.onm = (KReSONManager) servletContext
>> >> +
>> >> .getAttribute(KReSONManager.class.getName());
>> >> +               this.storeProvider = (OntologyStoreProvider)
>> >> servletContext
>> >> +
>> >> .getAttribute(OntologyStoreProvider.class.getName());
>> >> +               // Contingency code for missing components follows.
>> >> +               /*
>> >> +                * FIXME! The following code is required only for the
>> >> tests. This should
>> >> +                * be removed and the test should work without this code.
>> >> +                */
>> >> +               if (storeProvider == null) {
>> >> +                       log
>> >> +                                       .warn("No OntologyStoreProvider
>> >> in servlet context. Instantiating manually...");
>> >> +                       storeProvider = new
>> >> OntologyStorageProviderImpl();
>> >> +               }
>> >> +               if (onm == null) {
>> >> +                       log
>> >> +                                       .warn("No KReSONManager in
>> >> servlet context. Instantiating manually...");
>> >> +                       onm = new
>> >> ONManager(storeProvider.getActiveOntologyStorage(),
>> >> +                                       new Hashtable<String, Object>());
>> >> +               }
>> >>         if (kresRuleStore == null) {
>> >> -           System.err.println("WARNING: KReSRuleStore with stored rules
>> >> and recipes is missing in ServletContext. A new instance has been
>> >> created.");
>> >> -           this.kresRuleStore = new KReSRuleStore("");
>> >> -           System.err.println("PATH TO OWL FILE LOADED:
>> >> "+kresRuleStore.getFilePath());
>> >> -            /*throw new IllegalStateException(
>> >> -                    "KReSRuleStore with stored rules and recipes is
>> >> missing in ServletContext");*/
>> >> +                       log
>> >> +                                       .warn("No KReSRuleStore with
>> >> stored rules and recipes found in servlet context. Instantiating manually
>> >> with default values...");
>> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> >> +                                       new Hashtable<String, Object>(),
>> >> "");
>> >> +                       log
>> >> +                                       .debug("PATH TO OWL FILE LOADED:
>> >> "
>> >> +                                                       +
>> >> kresRuleStore.getFilePath());
>> >>          }
>> >>      }
>> >>
>> >>     /**
>> >> -     * Get a recipe with its rules from the rule base (that is the
>> >> ontology that contains the rules and the recipe).
>> >> +        * Get a recipe with its rules from the rule base (that is the
>> >> ontology that
>> >> +        * contains the rules and the recipe).
>> >>       *
>> >> -     * @param uri {A string contains the IRI full name of the recipe.}
>> >> +        * @param uri
>> >> +        *            {A string contains the IRI full name of the
>> >> recipe.}
>> >>       * @return Return: <br/>
>> >> -     *       200 The recipe is retrieved (import declarations point to
>> >> KReS Services) <br/>
>> >> +        *         200 The recipe is retrieved (import declarations point
>> >> to KReS
>> >> +        *         Services) <br/>
>> >>       *       404 The recipe does not exists in the manager <br/>
>> >>       *       500 Some error occurred
>> >>       *
>> >>       */
>> >>      @GET
>> >>      @Path("/{uri:.+}")
>> >> -    @Produces(value={KReSFormat.RDF_XML,
>> >> -                                KReSFormat.TURTLE,
>> >> -                                KReSFormat.OWL_XML,
>> >> -                                KReSFormat.FUNCTIONAL_OWL,
>> >> -                                KReSFormat.MANCHESTER_OWL,
>> >> -                                KReSFormat.RDF_JSON})
>> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> >> +                       KReSFormat.OWL_XML, KReSFormat.FUNCTIONAL_OWL,
>> >> +                       KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON })
>> >>      public Response getRecipe(@PathParam("uri") String uri){
>> >>        try{
>> >>
>> >>         KReSGetRecipe rule = new KReSGetRecipe(kresRuleStore);
>> >>
>> >> -       //String ID =
>> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> >> +                       // String ID =
>> >> +                       //
>> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> >>
>> >>         if(uri.equals("all")){
>> >>
>> >> @@ -108,32 +146,48 @@ public class Recipe extends NavigationMi
>> >>              return Response.status(Status.NOT_FOUND).build();
>> >>          }else{
>> >>
>> >> -            //The recipe is retrieved (import declarations point to KReS
>> >> Services)
>> >> +                                       // The recipe is retrieved
>> >> (import declarations point to
>> >> +                                       // KReS Services)
>> >>              OWLOntology onto = kresRuleStore.getOntology();
>> >> -            OWLOntology newmodel =
>> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> >> -            OWLDataFactory factory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> +                                       OWLOntology newmodel = OWLManager
>> >> +
>> >> .createOWLOntologyManager().createOntology(
>> >> +
>> >> onto.getOntologyID());
>> >> +                                       OWLDataFactory factory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >>
>> >> -            Iterator<OWLOntology> importedonto =
>> >> onto.getDirectImports().iterator();
>> >> +                                       Iterator<OWLOntology>
>> >> importedonto = onto
>> >> +
>> >> .getDirectImports().iterator();
>> >>              List<OWLOntologyChange> additions = new
>> >>              LinkedList<OWLOntologyChange>();
>> >> -            OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> +                                       OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >>
>> >>              while(importedonto.hasNext()){
>> >>                  OWLOntology auxonto = importedonto.next();
>> >> -                additions.add(new
>> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                               additions.add(new
>> >> AddImport(newmodel, auxfactory
>> >> +
>> >> .getOWLImportsDeclaration(auxonto
>> >> +
>> >>       .getOWLOntologyManager()
>> >> +
>> >>       .getOntologyDocumentIRI(auxonto))));
>> >>              }
>> >>
>> >>              if(!additions.isEmpty())
>> >> -
>> >> newmodel.getOWLOntologyManager().applyChanges(additions);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .applyChanges(additions);
>> >>
>> >>              for(int i = 0; i<recipe.size(); i++){
>> >> -                OWLNamedIndividual ind =
>> >> factory.getOWLNamedIndividual(recipe.get(i));
>> >> +                                               OWLNamedIndividual ind =
>> >> factory
>> >> +
>> >> .getOWLNamedIndividual(recipe.get(i));
>> >>                  Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> >> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .addAxioms(newmodel, ax);
>> >>
>> >>              }
>> >>
>> >>              try {
>> >> -
>> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> >> System.out);
>> >> +
>> >> OWLManager.createOWLOntologyManager().saveOntology(
>> >> +                                                               newmodel,
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >>       .getOntologyFormat(newmodel),
>> >> +
>> >> System.out);
>> >>               } catch (OWLOntologyStorageException e) {
>> >>                       // TODO Auto-generated catch block
>> >>                       e.printStackTrace();
>> >> @@ -150,30 +204,44 @@ public class Recipe extends NavigationMi
>> >>              //The recipe deos not exists in the manager
>> >>              return Response.status(Status.NOT_FOUND).build();
>> >>          }else{
>> >> -            //The recipe is retrieved (import declarations point to KReS
>> >> Services)
>> >> +                                       // The recipe is retrieved
>> >> (import declarations point to
>> >> +                                       // KReS Services)
>> >>              OWLOntology onto = kresRuleStore.getOntology();
>> >>
>> >> -            OWLDataFactory factory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> -            OWLObjectProperty prop =
>> >> factory.getOWLObjectProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> >> -            OWLNamedIndividual ind =
>> >> factory.getOWLNamedIndividual(IRI.create(uri));
>> >> -            Set<OWLIndividual> value = ind.getObjectPropertyValues(prop,
>> >> onto);
>> >> +                                       OWLDataFactory factory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >> +                                       OWLObjectProperty prop = factory
>> >> +
>> >> .getOWLObjectProperty(IRI
>> >> +
>> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> >> +                                       OWLNamedIndividual ind =
>> >> factory.getOWLNamedIndividual(IRI
>> >> +                                                       .create(uri));
>> >> +                                       Set<OWLIndividual> value =
>> >> ind.getObjectPropertyValues(
>> >> +                                                       prop, onto);
>> >>              Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> >>
>> >>              Iterator<OWLIndividual> iter = value.iterator();
>> >>
>> >> -            OWLOntology newmodel =
>> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> >> +                                       OWLOntology newmodel = OWLManager
>> >> +
>> >> .createOWLOntologyManager().createOntology(
>> >> +
>> >> onto.getOntologyID());
>> >>
>> >> -            Iterator<OWLOntology> importedonto =
>> >> onto.getDirectImports().iterator();
>> >> +                                       Iterator<OWLOntology>
>> >> importedonto = onto
>> >> +
>> >> .getDirectImports().iterator();
>> >>              List<OWLOntologyChange> additions = new
>> >>              LinkedList<OWLOntologyChange>();
>> >> -            OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> +                                       OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >>
>> >>              while(importedonto.hasNext()){
>> >>                  OWLOntology auxonto = importedonto.next();
>> >> -                additions.add(new
>> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                               additions.add(new
>> >> AddImport(newmodel, auxfactory
>> >> +
>> >> .getOWLImportsDeclaration(auxonto
>> >> +
>> >>       .getOWLOntologyManager()
>> >> +
>> >>       .getOntologyDocumentIRI(auxonto))));
>> >>              }
>> >>
>> >>              if(!additions.isEmpty())
>> >> -
>> >> newmodel.getOWLOntologyManager().applyChanges(additions);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .applyChanges(additions);
>> >>
>> >>              newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> >>
>> >> @@ -182,11 +250,16 @@ public class Recipe extends NavigationMi
>> >>                  ind = (OWLNamedIndividual) iter.next();
>> >>                  ax = onto.getAxioms(ind);
>> >>
>> >> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .addAxioms(newmodel, ax);
>> >>              }
>> >>
>> >>              try {
>> >> -
>> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> >> System.out);
>> >> +
>> >> OWLManager.createOWLOntologyManager().saveOntology(
>> >> +                                                               newmodel,
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >>       .getOntologyFormat(newmodel),
>> >> +
>> >> System.out);
>> >>               } catch (OWLOntologyStorageException e) {
>> >>                       // TODO Auto-generated catch block
>> >>                       e.printStackTrace();
>> >> @@ -204,8 +277,11 @@ public class Recipe extends NavigationMi
>> >>
>> >>     /**
>> >>       * To add a recipe without rules.
>> >> -     * @param recipe {A string contains the IRI of the recipe to be
>> >> added}
>> >> -     * @param description {A string contains a description of the rule}
>> >> +        *
>> >> +        * @param recipe
>> >> +        *            {A string contains the IRI of the recipe to be
>> >> added}
>> >> +        * @param description
>> >> +        *            {A string contains a description of the rule}
>> >>       * @return Return: <br/>
>> >>       *      200 The recipe has been added<br/>
>> >>       *      409 The recipe has not been added<br/>
>> >> @@ -213,21 +289,21 @@ public class Recipe extends NavigationMi
>> >>       */
>> >>      @POST
>> >>      @Consumes(MediaType.MULTIPART_FORM_DATA)
>> >> -    @Produces(value={KReSFormat.RDF_XML,
>> >> -                                KReSFormat.TURTLE,
>> >> -                                KReSFormat.OWL_XML,
>> >> -                                KReSFormat.FUNCTIONAL_OWL,
>> >> -                                KReSFormat.MANCHESTER_OWL,
>> >> -                                KReSFormat.RDF_JSON})
>> >> -    public Response addRecipe(@FormParam(value="recipe") String
>> >> recipe,@FormParam(value="description") String description){
>> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> >> +                       KReSFormat.OWL_XML, KReSFormat.FUNCTIONAL_OWL,
>> >> +                       KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON })
>> >> +       public Response addRecipe(@FormParam(value = "recipe") String
>> >> recipe,
>> >> +                       @FormParam(value = "description") String
>> >> description) {
>> >>
>> >>          try{
>> >>
>> >>              KReSAddRecipe instance = new KReSAddRecipe(kresRuleStore);
>> >>
>> >> -            //String ID =
>> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> >> +                       // String ID =
>> >> +                       //
>> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> >>
>> >> -            boolean ok = instance.addSimpleRecipe(IRI.create(recipe),
>> >> description);
>> >> +                       boolean ok =
>> >> instance.addSimpleRecipe(IRI.create(recipe),
>> >> +                                       description);
>> >>
>> >>                  if(!ok){
>> >>
>> >> @@ -245,9 +321,10 @@ public class Recipe extends NavigationMi
>> >>
>> >>     /**
>> >>       * To delete a recipe
>> >> -     * @param recipe {A tring contains an IRI of the recipe}
>> >> -     * @return
>> >> -     *      200 The recipe has been deleted<br/>
>> >> +        *
>> >> +        * @param recipe
>> >> +        *            {A tring contains an IRI of the recipe}
>> >> +        * @return 200 The recipe has been deleted<br/>
>> >>       *      409 The recipe has not been deleted<br/>
>> >>       *      500 Some error occurred
>> >>       */
>> >> @@ -260,7 +337,8 @@ public class Recipe extends NavigationMi
>> >>
>> >>              KReSRemoveRecipe instance = new
>> >>              KReSRemoveRecipe(kresRuleStore);
>> >>
>> >> -            //String ID =
>> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> >> +                       // String ID =
>> >> +                       //
>> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
>> >>
>> >>              boolean ok = instance.removeRecipe(IRI.create(recipe));
>> >>
>> >>
>> >> Modified:
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> >> ==============================================================================
>> >> ---
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> >> (original)
>> >> +++
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
>> >> Wed Dec 29 18:04:19 2010
>> >> @@ -5,27 +5,16 @@
>> >>
>> >>  package eu.iksproject.kres.jersey.manager;
>> >>
>> >> -import eu.iksproject.kres.api.rules.RuleStore;
>> >> -import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> >> -import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> >> -import eu.iksproject.kres.rules.manager.KReSAddRule;
>> >> -import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> >> -import eu.iksproject.kres.rules.manager.KReSGetRule;
>> >> -import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> >> -import eu.iksproject.kres.rules.manager.KReSRemoveRule;
>> >> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> >> -import eu.iksproject.kres.api.format.KReSFormat;
>> >> -
>> >>  import java.io.UnsupportedEncodingException;
>> >>  import java.net.URLEncoder;
>> >> -import java.util.ArrayList;
>> >> -import java.util.Collection;
>> >>  import java.util.HashMap;
>> >> +import java.util.Hashtable;
>> >>  import java.util.Iterator;
>> >>  import java.util.LinkedList;
>> >>  import java.util.List;
>> >>  import java.util.Set;
>> >>  import java.util.Vector;
>> >> +
>> >>  import javax.servlet.ServletContext;
>> >>  import javax.ws.rs.Consumes;
>> >>  import javax.ws.rs.DELETE;
>> >> @@ -42,24 +31,32 @@ import javax.ws.rs.core.MediaType;
>> >>  import javax.ws.rs.core.Response;
>> >>  import javax.ws.rs.core.Response.Status;
>> >>
>> >> -import org.codehaus.jettison.json.JSONArray;
>> >>  import org.semanticweb.owlapi.apibinding.OWLManager;
>> >> -import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
>> >> -import org.semanticweb.owlapi.model.AddAxiom;
>> >>  import org.semanticweb.owlapi.model.AddImport;
>> >>  import org.semanticweb.owlapi.model.IRI;
>> >> -import org.semanticweb.owlapi.model.OWLAxiom;
>> >>  import org.semanticweb.owlapi.model.OWLDataFactory;
>> >> -import org.semanticweb.owlapi.model.OWLIndividual;
>> >>  import org.semanticweb.owlapi.model.OWLIndividualAxiom;
>> >>  import org.semanticweb.owlapi.model.OWLNamedIndividual;
>> >> -import org.semanticweb.owlapi.model.OWLObjectProperty;
>> >> -import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
>> >>  import org.semanticweb.owlapi.model.OWLOntology;
>> >>  import org.semanticweb.owlapi.model.OWLOntologyChange;
>> >> -import org.semanticweb.owlapi.model.OWLOntologyCreationException;
>> >> -import org.semanticweb.owlapi.model.OWLOntologyManager;
>> >>  import org.semanticweb.owlapi.model.OWLOntologyStorageException;
>> >> +import org.slf4j.Logger;
>> >> +import org.slf4j.LoggerFactory;
>> >> +
>> >> +import eu.iksproject.kres.api.format.KReSFormat;
>> >> +import eu.iksproject.kres.api.manager.KReSONManager;
>> >> +import eu.iksproject.kres.api.rules.RuleStore;
>> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>> >> +import eu.iksproject.kres.jersey.resource.NavigationMixin;
>> >> +import eu.iksproject.kres.manager.ONManager;
>> >> +import eu.iksproject.kres.rules.manager.KReSAddRecipe;
>> >> +import eu.iksproject.kres.rules.manager.KReSAddRule;
>> >> +import eu.iksproject.kres.rules.manager.KReSGetRecipe;
>> >> +import eu.iksproject.kres.rules.manager.KReSGetRule;
>> >> +import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
>> >> +import eu.iksproject.kres.rules.manager.KReSRemoveRule;
>> >> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>> >>
>> >>  /**
>> >>   *
>> >> @@ -70,40 +67,74 @@ import org.semanticweb.owlapi.model.OWLO
>> >>  @Path("/rule")
>> >>  public class Rule extends NavigationMixin{
>> >>
>> >> -    private static RuleStore kresRuleStore;
>> >> +       protected KReSONManager onm;
>> >> +       protected OntologyStoreProvider storeProvider;
>> >> +
>> >> +       private Logger log = LoggerFactory.getLogger(getClass());
>> >> +
>> >> +       private RuleStore kresRuleStore;
>> >>      private HashMap<IRI, String> map;
>> >>      private String desc;
>> >>
>> >>     /**
>> >>       * To get the KReSRuleStore where are stored the rules and the
>> >>       recipes
>> >>       *
>> >> -     * @param servletContext {To get the context where the REST service
>> >> is running.}
>> >> +        * @param servletContext
>> >> +        *            {To get the context where the REST service is
>> >> running.}
>> >>       */
>> >>      public Rule(@Context ServletContext servletContext){
>> >> -       this.kresRuleStore = (RuleStore)
>> >> servletContext.getAttribute(RuleStore.class.getName());
>> >> -
>> >> +               this.kresRuleStore = (RuleStore) servletContext
>> >> +                               .getAttribute(RuleStore.class.getName());
>> >> +               this.onm = (KReSONManager) servletContext
>> >> +
>> >> .getAttribute(KReSONManager.class.getName());
>> >> +               this.storeProvider = (OntologyStoreProvider)
>> >> servletContext
>> >> +
>> >> .getAttribute(OntologyStoreProvider.class.getName());
>> >> +               // Contingency code for missing components follows.
>> >> +               /*
>> >> +                * FIXME! The following code is required only for the
>> >> tests. This should
>> >> +                * be removed and the test should work without this code.
>> >> +                */
>> >> +               if (storeProvider == null) {
>> >> +                       log
>> >> +                                       .warn("No OntologyStoreProvider
>> >> in servlet context. Instantiating manually...");
>> >> +                       storeProvider = new
>> >> OntologyStorageProviderImpl();
>> >> +               }
>> >> +               if (onm == null) {
>> >> +                       log
>> >> +                                       .warn("No KReSONManager in
>> >> servlet context. Instantiating manually...");
>> >> +                       onm = new
>> >> ONManager(storeProvider.getActiveOntologyStorage(),
>> >> +                                       new Hashtable<String, Object>());
>> >> +               }
>> >>         if (kresRuleStore == null) {
>> >> -           System.err.println("WARNING: KReSRuleStore with stored rules
>> >> and recipes is missing in ServletContext. A new instance has been
>> >> created.");
>> >> -           this.kresRuleStore = new KReSRuleStore("");
>> >> -           System.err.println("PATH TO OWL FILE LOADED:
>> >> "+kresRuleStore.getFilePath());
>> >> -            /*throw new IllegalStateException(
>> >> -                    "KReSRuleStore with stored rules and recipes is
>> >> missing in ServletContext");*/
>> >> +                       log
>> >> +                                       .warn("No KReSRuleStore with
>> >> stored rules and recipes found in servlet context. Instantiating manually
>> >> with default values...");
>> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> >> +                                       new Hashtable<String, Object>(),
>> >> "");
>> >> +                       log
>> >> +                                       .debug("PATH TO OWL FILE LOADED:
>> >> "
>> >> +                                                       +
>> >> kresRuleStore.getFilePath());
>> >>          }
>> >>      }
>> >>
>> >>     /**
>> >> -     * Get a rule from the rule base (that is the ontology that contains
>> >> the rules and the recipe).
>> >> -     * curl -v -X GET
>> >> http://localhost:8080/kres/rule/http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule
>> >> -     * @param uri {A string contains the IRI full name of the rule.}
>> >> +        * Get a rule from the rule base (that is the ontology that
>> >> contains the
>> >> +        * rules and the recipe). curl -v -X GET
>> >> +        * http://localhost:8080/kres/rule/http
>> >> +        * ://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule
>> >> +        *
>> >> +        * @param uri
>> >> +        *            {A string contains the IRI full name of the rule.}
>> >>       * @return Return: <br/>
>> >> -     *       200 The rule is retrieved (import declarations point to
>> >> KReS Services) <br/>
>> >> +        *         200 The rule is retrieved (import declarations point
>> >> to KReS
>> >> +        *         Services) <br/>
>> >>       *       404 The rule does not exists in the manager <br/>
>> >>       *       500 Some error occurred
>> >>       *
>> >>       */
>> >>      @GET
>> >>      @Path("/{uri:.+}")
>> >> -
>> >> @Produces(value={KReSFormat.RDF_XML,KReSFormat.TURTLE,KReSFormat.OWL_XML})
>> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> >> +                       KReSFormat.OWL_XML })
>> >>      public Response getRule(@PathParam("uri") String uri){
>> >>
>> >>        try{
>> >> @@ -119,29 +150,44 @@ public class Rule extends NavigationMixi
>> >>          }else{
>> >>
>> >>              OWLOntology onto = kresRuleStore.getOntology();
>> >> -            OWLOntology newmodel =
>> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> >> -            OWLDataFactory factory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> +                                       OWLOntology newmodel = OWLManager
>> >> +
>> >> .createOWLOntologyManager().createOntology(
>> >> +
>> >> onto.getOntologyID());
>> >> +                                       OWLDataFactory factory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >>
>> >> -            Iterator<OWLOntology> importedonto =
>> >> onto.getDirectImports().iterator();
>> >> +                                       Iterator<OWLOntology>
>> >> importedonto = onto
>> >> +
>> >> .getDirectImports().iterator();
>> >>              List<OWLOntologyChange> additions = new
>> >>              LinkedList<OWLOntologyChange>();
>> >> -            OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> +                                       OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >>
>> >>              while(importedonto.hasNext()){
>> >>                  OWLOntology auxonto = importedonto.next();
>> >> -                additions.add(new
>> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                               additions.add(new
>> >> AddImport(newmodel, auxfactory
>> >> +
>> >> .getOWLImportsDeclaration(auxonto
>> >> +
>> >>       .getOWLOntologyManager()
>> >> +
>> >>       .getOntologyDocumentIRI(auxonto))));
>> >>              }
>> >>
>> >>              if(!additions.isEmpty())
>> >> -
>> >> newmodel.getOWLOntologyManager().applyChanges(additions);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .applyChanges(additions);
>> >>
>> >>              while(keys.hasNext()){
>> >> -                OWLNamedIndividual ind =
>> >> factory.getOWLNamedIndividual(keys.next());
>> >> +                                               OWLNamedIndividual ind =
>> >> factory
>> >> +
>> >> .getOWLNamedIndividual(keys.next());
>> >>                  Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> >> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .addAxioms(newmodel, ax);
>> >>              }
>> >>
>> >>              try {
>> >> -
>> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> >> System.out);
>> >> +
>> >> OWLManager.createOWLOntologyManager().saveOntology(
>> >> +                                                               newmodel,
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >>       .getOntologyFormat(newmodel),
>> >> +
>> >> System.out);
>> >>               } catch (OWLOntologyStorageException e) {
>> >>                       // TODO Auto-generated catch block
>> >>                       e.printStackTrace();
>> >> @@ -159,27 +205,41 @@ public class Rule extends NavigationMixi
>> >>          }else{
>> >>              OWLOntology onto = kresRuleStore.getOntology();
>> >>
>> >> -            OWLDataFactory factory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> -            OWLNamedIndividual ind =
>> >> factory.getOWLNamedIndividual(IRI.create(uri));
>> >> +                                       OWLDataFactory factory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >> +                                       OWLNamedIndividual ind =
>> >> factory.getOWLNamedIndividual(IRI
>> >> +                                                       .create(uri));
>> >>              Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
>> >> -            OWLOntology newmodel =
>> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
>> >> +                                       OWLOntology newmodel = OWLManager
>> >> +
>> >> .createOWLOntologyManager().createOntology(
>> >> +
>> >> onto.getOntologyID());
>> >>
>> >> -            Iterator<OWLOntology> importedonto =
>> >> onto.getDirectImports().iterator();
>> >> +                                       Iterator<OWLOntology>
>> >> importedonto = onto
>> >> +
>> >> .getDirectImports().iterator();
>> >>              List<OWLOntologyChange> additions = new
>> >>              LinkedList<OWLOntologyChange>();
>> >> -            OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager().getOWLDataFactory();
>> >> +                                       OWLDataFactory auxfactory =
>> >> onto.getOWLOntologyManager()
>> >> +
>> >> .getOWLDataFactory();
>> >>
>> >>              while(importedonto.hasNext()){
>> >>                  OWLOntology auxonto = importedonto.next();
>> >> -                additions.add(new
>> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                               additions.add(new
>> >> AddImport(newmodel, auxfactory
>> >> +
>> >> .getOWLImportsDeclaration(auxonto
>> >> +
>> >>       .getOWLOntologyManager()
>> >> +
>> >>       .getOntologyDocumentIRI(auxonto))));
>> >>              }
>> >>
>> >>              if(!additions.isEmpty())
>> >> -
>> >> newmodel.getOWLOntologyManager().applyChanges(additions);
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >> .applyChanges(additions);
>> >>
>> >>              newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
>> >>
>> >>              try {
>> >> -
>> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
>> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
>> >> System.out);
>> >> +
>> >> OWLManager.createOWLOntologyManager().saveOntology(
>> >> +                                                               newmodel,
>> >> +
>> >> newmodel.getOWLOntologyManager()
>> >> +
>> >>       .getOntologyFormat(newmodel),
>> >> +
>> >> System.out);
>> >>               } catch (OWLOntologyStorageException e) {
>> >>                       // TODO Auto-generated catch block
>> >>                       e.printStackTrace();
>> >> @@ -197,15 +257,16 @@ public class Rule extends NavigationMixi
>> >>
>> >>      @GET
>> >>      @Path("/of-recipe/{uri:.+}")
>> >> -    @Produces(value={KReSFormat.RDF_XML,
>> >> -                                KReSFormat.RDF_JSON})
>> >> -
>> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.RDF_JSON })
>> >>      public Response getRulesOfRecipe(@PathParam("uri") String
>> >>      recipeURI){
>> >>
>> >>       KReSGetRule kReSGetRule = new KReSGetRule(kresRuleStore);
>> >>       String recipeURIEnc;
>> >>               try {
>> >> -                       recipeURIEnc =
>> >> URLEncoder.encode("http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA",
>> >> "UTF-8");
>> >> +                       recipeURIEnc = URLEncoder
>> >> +                                       .encode(
>> >> +
>> >> "http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA",
>> >> +                                                       "UTF-8");
>> >>                       System.out.println("RECIPE : "+recipeURIEnc);
>> >>               } catch (UnsupportedEncodingException e) {
>> >>                       // TODO Auto-generated catch block
>> >> @@ -213,19 +274,32 @@ public class Rule extends NavigationMixi
>> >>               }
>> >>
>> >>       System.out.println("RECIPE IRI : "+IRI.create(recipeURI).toString());
>> >> -       OWLOntology ontology =
>> >> kReSGetRule.getAllRulesOfARecipe(IRI.create(recipeURI));
>> >> +               OWLOntology ontology =
>> >> kReSGetRule.getAllRulesOfARecipe(IRI
>> >> +                               .create(recipeURI));
>> >>
>> >>       return Response.ok(ontology).build();
>> >>
>> >> -
>> >>      }
>> >> +
>> >>     /**
>> >> -     * To add a rule to a recipe at the end of the sequence.
>> >> -     * curl -v -X POST -F
>> >> "recipe=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaParentRecipe"
>> >> -F "rule=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaRuleNEW"
>> >> -F "kres-syntax=body -> head" -F "description=prova di aggiunta regola"
>> >> http://localhost:8080/kres/rule
>> >> -     * @param recipe {A string contains the IRI of the recipe where to
>> >> add the rule}
>> >> -     * @param rule {A string contains the IRI of the rule to be added at
>> >> the recipe}
>> >> -     * @param kres_syntax {A string contains the body and the head of
>> >> the kres rule. If not specified the rule is search in the Ontology
>> >> otherwise is added as new.}
>> >> -     * @param description {A string contains a description of the rule}
>> >> +        * To add a rule to a recipe at the end of the sequence. curl -v
>> >> -X POST -F
>> >> +        *
>> >> "recipe=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaParentRecipe"
>> >> +        * -F
>> >> "rule=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaRuleNEW"
>> >> +        * -F "kres-syntax=body -> head" -F "description=prova di
>> >> aggiunta regola"
>> >> +        * http://localhost:8080/kres/rule
>> >> +        *
>> >> +        * @param recipe
>> >> +        *            {A string contains the IRI of the recipe where to
>> >> add the
>> >> +        *            rule}
>> >> +        * @param rule
>> >> +        *            {A string contains the IRI of the rule to be added
>> >> at the
>> >> +        *            recipe}
>> >> +        * @param kres_syntax
>> >> +        *            {A string contains the body and the head of the
>> >> kres rule. If
>> >> +        *            not specified the rule is search in the Ontology
>> >> otherwise is
>> >> +        *            added as new.}
>> >> +        * @param description
>> >> +        *            {A string contains a description of the rule}
>> >>       * @return Return: <br/>
>> >>       *      200 The rule has been added <br/>
>> >>       *      204 The rule has not been added <br/>
>> >> @@ -236,7 +310,10 @@ public class Rule extends NavigationMixi
>> >>       */
>> >>      @POST
>> >>      @Consumes(MediaType.MULTIPART_FORM_DATA)
>> >> -    public Response addRuleToRecipe(@FormParam(value="recipe") String
>> >> recipe,@FormParam(value="rule") String
>> >> rule,@FormParam(value="kres-syntax") String
>> >> kres_syntax,@FormParam(value="description") String description){
>> >> +       public Response addRuleToRecipe(@FormParam(value = "recipe")
>> >> String recipe,
>> >> +                       @FormParam(value = "rule") String rule,
>> >> +                       @FormParam(value = "kres-syntax") String
>> >> kres_syntax,
>> >> +                       @FormParam(value = "description") String
>> >> description) {
>> >>
>> >>  //        System.err.println("recipe "+recipe);
>> >>  //        System.err.println("rule " + rule);
>> >> @@ -306,7 +383,8 @@ public class Rule extends NavigationMixi
>> >>           if((kres_syntax!=null)&(description!=null)){
>> >>              //Get the rule
>> >>              KReSAddRule inrule = new KReSAddRule(kresRuleStore);
>> >> -            boolean ok =
>> >> inrule.addRule(IRI.create(rule),kres_syntax,description);
>> >> +                               boolean ok =
>> >> inrule.addRule(IRI.create(rule), kres_syntax,
>> >> +                                               description);
>> >>              if(!ok){
>> >>                  System.err.println("PROBLEM TO ADD: "+rule);
>> >>                  return Response.status(Status.CONFLICT).build();
>> >> @@ -341,7 +419,6 @@ public class Rule extends NavigationMixi
>> >>                  return Response.status(Status.CONFLICT).build();
>> >>              }
>> >>
>> >> -
>> >>              //Add the recipe with the new rule
>> >>              KReSAddRecipe newadd = new KReSAddRecipe(kresRuleStore);
>> >>              ok = newadd.addRecipe(IRI.create(recipe), ruleseq, desc);
>> >> @@ -361,14 +438,17 @@ public class Rule extends NavigationMixi
>> >>      }
>> >>
>> >>     /**
>> >> -     * To delete a rule from a recipe or from the ontology. If the
>> >> recipe is not specified the rule is deleted from the ontology.
>> >> -     * curl -v -X DELETE -G \
>> >> -     * -d
>> >> recipe="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRecipe"
>> >> \
>> >> -     * -d
>> >> rule="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentNewRule"
>> >> \
>> >> +        * To delete a rule from a recipe or from the ontology. If the
>> >> recipe is not
>> >> +        * specified the rule is deleted from the ontology. curl -v -X
>> >> DELETE -G \
>> >> +        * -d recipe=
>> >> +        *
>> >> "http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRecipe" \ -d
>> >> +        * rule
>> >> +        *
>> >> ="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentNewRule" \
>> >>       * http://localhost:port/kres/rule
>> >>      *
>> >>       * @Param rule {A string contains an IRI of the rule to be removed}
>> >> -     * @param recipe {A string contains an IRI of the recipe where
>> >> remove the rule}
>> >> +        * @param recipe
>> >> +        *            {A string contains an IRI of the recipe where
>> >> remove the rule}
>> >>       * @return Return: <br/>
>> >>       *      200 The rule has been deleted<br/>
>> >>       *      204 The rule has not been deleted<br/>
>> >> @@ -379,7 +459,8 @@ public class Rule extends NavigationMixi
>> >>      @DELETE
>> >>      //@Consumes(MediaType.TEXT_PLAIN)
>> >>      @Produces(KReSFormat.TEXT_PLAIN)
>> >> -    public Response removeRule(@QueryParam(value="rule") String
>> >> rule,@QueryParam(value="recipe") String recipe){
>> >> +       public Response removeRule(@QueryParam(value = "rule") String
>> >> rule,
>> >> +                       @QueryParam(value = "recipe") String recipe) {
>> >>
>> >>          boolean ok;
>> >>
>> >> @@ -408,7 +489,8 @@ public class Rule extends NavigationMixi
>> >>              }
>> >>
>> >>              KReSRemoveRule remove = new KReSRemoveRule(kresRuleStore);
>> >> -            ok =
>> >> remove.removeRuleFromRecipe(IRI.create(rule),IRI.create(recipe));
>> >> +                               ok =
>> >> remove.removeRuleFromRecipe(IRI.create(rule), IRI
>> >> +                                               .create(recipe));
>> >>              if(ok){
>> >>                  kresRuleStore.saveOntology();
>> >>                  return Response.status(Status.OK).build();
>> >>
>> >> Modified:
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> >> URL:
>> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java?rev=1053689&r1=1053688&r2=1053689&view=diff
>> >> ==============================================================================
>> >> ---
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> >> (original)
>> >> +++
>> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
>> >> Wed Dec 29 18:04:19 2010
>> >> @@ -5,31 +5,14 @@
>> >>
>> >>  package eu.iksproject.kres.jersey.reasoners;
>> >>
>> >> -import com.hp.hpl.jena.rdf.model.Model;
>> >> -import com.hp.hpl.jena.rdf.model.ModelFactory;
>> >> -import com.hp.hpl.jena.rdf.model.Resource;
>> >> -import eu.iksproject.kres.api.format.KReSFormat;
>> >> -import eu.iksproject.kres.api.manager.ontology.OntologyScope;
>> >> -import eu.iksproject.kres.api.manager.ontology.OntologySpace;
>> >> -import eu.iksproject.kres.api.manager.ontology.ScopeRegistry;
>> >> -import eu.iksproject.kres.api.manager.ontology.SessionOntologySpace;
>> >> -import eu.iksproject.kres.api.rules.KReSRule;
>> >> -import eu.iksproject.kres.api.rules.NoSuchRecipeException;
>> >> -import eu.iksproject.kres.api.rules.RuleStore;
>> >> -import eu.iksproject.kres.api.rules.util.KReSRuleList;
>> >> -import eu.iksproject.kres.manager.ONManager;
>> >> -import eu.iksproject.kres.reasoners.KReSCreateReasoner;
>> >> -import eu.iksproject.kres.reasoners.KReSRunReasoner;
>> >> -import eu.iksproject.kres.reasoners.KReSRunRules;
>> >> -import eu.iksproject.kres.rules.KReSKB;
>> >> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> >> -import eu.iksproject.kres.rules.parser.KReSRuleParser;
>> >>  import java.io.File;
>> >>  import java.net.URL;
>> >> +import java.util.Hashtable;
>> >>  import java.util.Iterator;
>> >>  import java.util.LinkedList;
>> >>  import java.util.List;
>> >>  import java.util.Set;
>> >> +
>> >>  import javax.servlet.ServletContext;
>> >>  import javax.ws.rs.Consumes;
>> >>  import javax.ws.rs.FormParam;
>> >> @@ -41,6 +24,7 @@ import javax.ws.rs.core.Context;
>> >>  import javax.ws.rs.core.MediaType;
>> >>  import javax.ws.rs.core.Response;
>> >>  import javax.ws.rs.core.Response.Status;
>> >> +
>> >>  import org.semanticweb.owlapi.apibinding.OWLManager;
>> >>  import org.semanticweb.owlapi.model.AddImport;
>> >>  import org.semanticweb.owlapi.model.IRI;
>> >> @@ -55,7 +39,32 @@ import org.semanticweb.owlapi.model.OWLO
>> >>  import org.semanticweb.owlapi.model.OWLOntologyChange;
>> >>  import org.semanticweb.owlapi.model.OWLOntologyManager;
>> >>  import org.semanticweb.owlapi.reasoner.InconsistentOntologyException;
>> >> +import org.slf4j.Logger;
>> >> +import org.slf4j.LoggerFactory;
>> >>
>> >> +import com.hp.hpl.jena.rdf.model.Model;
>> >> +import com.hp.hpl.jena.rdf.model.ModelFactory;
>> >> +import com.hp.hpl.jena.rdf.model.Resource;
>> >> +
>> >> +import eu.iksproject.kres.api.format.KReSFormat;
>> >> +import eu.iksproject.kres.api.manager.KReSONManager;
>> >> +import eu.iksproject.kres.api.manager.ontology.OntologyScope;
>> >> +import eu.iksproject.kres.api.manager.ontology.OntologySpace;
>> >> +import eu.iksproject.kres.api.manager.ontology.ScopeRegistry;
>> >> +import eu.iksproject.kres.api.manager.ontology.SessionOntologySpace;
>> >> +import eu.iksproject.kres.api.rules.KReSRule;
>> >> +import eu.iksproject.kres.api.rules.NoSuchRecipeException;
>> >> +import eu.iksproject.kres.api.rules.RuleStore;
>> >> +import eu.iksproject.kres.api.rules.util.KReSRuleList;
>> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
>> >> +import eu.iksproject.kres.manager.ONManager;
>> >> +import eu.iksproject.kres.reasoners.KReSCreateReasoner;
>> >> +import eu.iksproject.kres.reasoners.KReSRunReasoner;
>> >> +import eu.iksproject.kres.reasoners.KReSRunRules;
>> >> +import eu.iksproject.kres.rules.KReSKB;
>> >> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
>> >> +import eu.iksproject.kres.rules.parser.KReSRuleParser;
>> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
>> >>
>> >>  /**
>> >>   *
>> >> @@ -68,49 +77,94 @@ public class Classify {
>> >>       private OWLOntology inputowl;
>> >>       private OWLOntology scopeowl;
>> >>
>> >> +       protected KReSONManager onm;
>> >> +       protected OntologyStoreProvider storeProvider;
>> >> +
>> >> +       private Logger log = LoggerFactory.getLogger(getClass());
>> >> +
>> >>      /**
>> >>       * To get the KReSRuleStore where are stored the rules and the
>> >>       recipes
>> >>       *
>> >> -     * @param servletContext {To get the context where the REST service
>> >> is running.}
>> >> +        * @param servletContext
>> >> +        *            {To get the context where the REST service is
>> >> running.}
>> >>       */
>> >>      public Classify(@Context ServletContext servletContext){
>> >> -       this.kresRuleStore = (RuleStore)
>> >> servletContext.getAttribute(RuleStore.class.getName());
>> >> +               this.kresRuleStore = (RuleStore) servletContext
>> >> +                               .getAttribute(RuleStore.class.getName());
>> >> +               this.onm = (KReSONManager) servletContext
>> >> +
>> >> .getAttribute(KReSONManager.class.getName());
>> >> +               this.storeProvider = (OntologyStoreProvider)
>> >> servletContext
>> >> +
>> >> .getAttribute(OntologyStoreProvider.class.getName());
>> >> +               // Contingency code for missing components follows.
>> >> +               /*
>> >> +                * FIXME! The following code is required only for the
>> >> tests. This should
>> >> +                * be removed and the test should work without this code.
>> >> +                */
>> >> +               if (storeProvider == null) {
>> >> +                       log
>> >> +                                       .warn("No OntologyStoreProvider
>> >> in servlet context. Instantiating manually...");
>> >> +                       storeProvider = new
>> >> OntologyStorageProviderImpl();
>> >> +               }
>> >> +               if (onm == null) {
>> >> +                       log
>> >> +                                       .warn("No KReSONManager in
>> >> servlet context. Instantiating manually...");
>> >> +                       onm = new
>> >> ONManager(storeProvider.getActiveOntologyStorage(),
>> >> +                                       new Hashtable<String, Object>());
>> >> +               }
>> >>         if (kresRuleStore == null) {
>> >> -            System.err.println("WARNING: KReSRuleStore with stored rules
>> >> and recipes is missing in ServletContext. A new instance has been
>> >> created.");
>> >> -            this.kresRuleStore = new KReSRuleStore("");
>> >> -            System.err.println("PATH TO OWL FILE LOADED:
>> >> "+kresRuleStore.getFilePath());
>> >> -//            throw new IllegalStateException(
>> >> -//                    "KReSRuleStore with stored rules and recipes is
>> >> missing in ServletContext");
>> >> +                       log
>> >> +                                       .warn("No KReSRuleStore with
>> >> stored rules and recipes found in servlet context. Instantiating manually
>> >> with default values...");
>> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
>> >> +                                       new Hashtable<String, Object>(),
>> >> "");
>> >> +                       log
>> >> +                                       .debug("PATH TO OWL FILE LOADED:
>> >> "
>> >> +                                                       +
>> >> kresRuleStore.getFilePath());
>> >>          }
>> >>      }
>> >>
>> >>       /**
>> >>       * To trasform a sequence of rules to a Jena Model
>> >> -     * @param owl {OWLOntology object contains a single recipe}
>> >> +        *
>> >> +        * @param owl
>> >> +        *            {OWLOntology object contains a single recipe}
>> >>       * @return {A jena rdf model contains the SWRL rule.}
>> >>       */
>> >> -    private Model fromRecipeToModel(OWLOntology owl) throws
>> >> NoSuchRecipeException{
>> >> +       private Model fromRecipeToModel(OWLOntology owl)
>> >> +                       throws NoSuchRecipeException {
>> >>
>> >> -        RuleStore store = new KReSRuleStore(owl);
>> >> +               // FIXME: why the heck is this method re-instantiating a
>> >> rule store?!?
>> >> +               RuleStore store = new KReSRuleStore(onm,
>> >> +                               new Hashtable<String, Object>(), owl);
>> >>          Model jenamodel = ModelFactory.createDefaultModel();
>> >>
>> >> -        OWLDataFactory factory =
>> >> owl.getOWLOntologyManager().getOWLDataFactory();
>> >> -        OWLClass ontocls =
>> >> factory.getOWLClass(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"));
>> >> +               OWLDataFactory factory = owl.getOWLOntologyManager()
>> >> +                               .getOWLDataFactory();
>> >> +               OWLClass ontocls = factory
>> >> +                               .getOWLClass(IRI
>> >> +
>> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"));
>> >>          Set<OWLClassAssertionAxiom> cls =
>> >>          owl.getClassAssertionAxioms(ontocls);
>> >>          Iterator<OWLClassAssertionAxiom> iter = cls.iterator();
>> >>          IRI recipeiri =
>> >>          IRI.create(iter.next().getIndividual().toStringID());
>> >>
>> >> -       OWLIndividual recipeIndividual =
>> >> factory.getOWLNamedIndividual(recipeiri);
>> >> +               OWLIndividual recipeIndividual = factory
>> >> +                               .getOWLNamedIndividual(recipeiri);
>> >>
>> >> -       OWLObjectProperty objectProperty =
>> >> factory.getOWLObjectProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> >> -       Set<OWLIndividual> rules =
>> >> recipeIndividual.getObjectPropertyValues(objectProperty,
>> >> store.getOntology());
>> >> +               OWLObjectProperty objectProperty = factory
>> >> +                               .getOWLObjectProperty(IRI
>> >> +
>> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
>> >> +               Set<OWLIndividual> rules =
>> >> recipeIndividual.getObjectPropertyValues(
>> >> +                               objectProperty, store.getOntology());
>> >>          String kReSRules = "";
>> >>          for(OWLIndividual rule : rules){
>> >> -                       OWLDataProperty hasBodyAndHead =
>> >> factory.getOWLDataProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"));
>> >> -                       Set<OWLLiteral> kReSRuleLiterals =
>> >> rule.getDataPropertyValues(hasBodyAndHead, store.getOntology());
>> >> +                       OWLDataProperty hasBodyAndHead = factory
>> >> +                                       .getOWLDataProperty(IRI
>> >> +
>> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"));
>> >> +                       Set<OWLLiteral> kReSRuleLiterals =
>> >> rule.getDataPropertyValues(
>> >> +                                       hasBodyAndHead,
>> >> store.getOntology());
>> >>
>> >>                       for(OWLLiteral kReSRuleLiteral : kReSRuleLiterals){
>> >> -                               kReSRules += kReSRuleLiteral.getLiteral()
>> >> + System.getProperty("line.separator");
>> >> +                               kReSRules += kReSRuleLiteral.getLiteral()
>> >> +                                               +
>> >> System.getProperty("line.separator");
>> >>                       }
>> >>               }
>> >>
>> >> @@ -128,13 +182,24 @@ public class Classify {
>> >>      }
>> >>
>> >>     /**
>> >> -     * To run a classifying reasoner on a RDF input File or IRI on the
>> >> base of a Scope (or an ontology) and a recipe. Can be used either HermiT
>> >> or an owl-link server reasoner end-point
>> >> -     * @param session {A string contains the session IRI used to
>> >> classify the input.}
>> >> -     * @param scope {A string contains either a specific scope's
>> >> ontology or the scope IRI used to classify the input.}
>> >> -     * @param recipe {A string contains the recipe IRI from the service
>> >> http://localhost:port/kres/recipe/recipeName.}
>> >> +        * To run a classifying reasoner on a RDF input File or IRI on
>> >> the base of a
>> >> +        * Scope (or an ontology) and a recipe. Can be used either HermiT
>> >> or an
>> >> +        * owl-link server reasoner end-point
>> >> +        *
>> >> +        * @param session
>> >> +        *            {A string contains the session IRI used to classify
>> >> the
>> >> +        *            input.}
>> >> +        * @param scope
>> >> +        *            {A string contains either a specific scope's
>> >> ontology or the
>> >> +        *            scope IRI used to classify the input.}
>> >> +        * @param recipe
>> >> +        *            {A string contains the recipe IRI from the service
>> >> +        *            http://localhost:port/kres/recipe/recipeName.}
>> >>       * @Param file {A file in a RDF (eihter RDF/XML or owl) to be
>> >>       classified.}
>> >> -     * @Param input_graph {A string contains the IRI of RDF (either
>> >> RDF/XML or OWL) to be classified.}
>> >> -     * @Param owllink_endpoint {A string contains the ressoner server
>> >> end-point URL.}
>> >> +        * @Param input_graph {A string contains the IRI of RDF (either
>> >> RDF/XML or
>> >> +        *        OWL) to be classified.}
>> >> +        * @Param owllink_endpoint {A string contains the ressoner server
>> >> end-point
>> >> +        *        URL.}
>> >>       * @return Return: <br/>
>> >>       *          200 The ontology is retrieved, containing only class
>> >>       axioms <br/>
>> >>       *          400 To run the session is needed the scope <br/>
>> >> @@ -144,8 +209,15 @@ public class Classify {
>> >>       */
>> >>      @POST
>> >>      @Consumes(MediaType.MULTIPART_FORM_DATA)
>> >> -
>> >> @Produces(value={KReSFormat.RDF_XML,KReSFormat.TURTLE,KReSFormat.OWL_XML})
>> >> -    public Response ontologyClassify(@FormParam(value="session") String
>> >> session,@FormParam(value="scope") String scope,@FormParam(value="recipe")
>> >> String recipe,@FormParam(value="input-graph") String
>> >> input_graph,@FormParam(value="file") File
>> >> file,@FormParam(value="owllink-endpoint") String owllink_endpoint){
>> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
>> >> +                       KReSFormat.OWL_XML })
>> >> +       public Response ontologyClassify(
>> >> +                       @FormParam(value = "session") String session,
>> >> +                       @FormParam(value = "scope") String scope,
>> >> +                       @FormParam(value = "recipe") String recipe,
>> >> +                       @FormParam(value = "input-graph") String
>> >> input_graph,
>> >> +                       @FormParam(value = "file") File file,
>> >> +                       @FormParam(value = "owllink-endpoint") String
>> >> owllink_endpoint) {
>> >>
>> >>        try{
>> >>
>> >> @@ -162,22 +234,28 @@ public class Classify {
>> >>
>> >>        //Load input file or graph
>> >>        if(file!=null)
>> >> -        this.inputowl =
>> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(file);
>> >> +                               this.inputowl =
>> >> OWLManager.createOWLOntologyManager()
>> >> +
>> >> .loadOntologyFromOntologyDocument(file);
>> >>        if(input_graph!=null)
>> >> -        this.inputowl =
>> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(input_graph));
>> >> +                               this.inputowl =
>> >> OWLManager.createOWLOntologyManager()
>> >> +
>> >> .loadOntologyFromOntologyDocument(
>> >> +
>> >> IRI.create(input_graph));
>> >>        if(inputowl==null&&(session==null||scope==null))
>> >>          return Response.status(Status.NOT_FOUND).build();
>> >>        if(inputowl==null){
>> >>            if(scope!=null)
>> >> -            this.inputowl =
>> >> OWLManager.createOWLOntologyManager().createOntology();
>> >> +                                       this.inputowl =
>> >> OWLManager.createOWLOntologyManager()
>> >> +
>> >> .createOntology();
>> >>            else{
>> >> -            this.inputowl =
>> >> OWLManager.createOWLOntologyManager().createOntology();
>> >> +                                       this.inputowl =
>> >> OWLManager.createOWLOntologyManager()
>> >> +
>> >> .createOntology();
>> >>            }
>> >>        }
>> >>
>> >>         //Create list to add ontologies as imported
>> >>         OWLOntologyManager mgr = inputowl.getOWLOntologyManager();
>> >> -       OWLDataFactory factory =
>> >> inputowl.getOWLOntologyManager().getOWLDataFactory();
>> >> +                       OWLDataFactory factory =
>> >> inputowl.getOWLOntologyManager()
>> >> +                                       .getOWLDataFactory();
>> >>         List<OWLOntologyChange> additions = new
>> >>         LinkedList<OWLOntologyChange>();
>> >>
>> >>         boolean ok = false;
>> >> @@ -187,16 +265,22 @@ public class Classify {
>> >>        if((scope!=null)&&(session==null))
>> >>        try{
>> >>            IRI iri = IRI.create(scope);
>> >> -          ScopeRegistry reg = ONManager.get().getScopeRegistry();
>> >> +                                       ScopeRegistry reg =
>> >> onm.getScopeRegistry();
>> >>            OntologyScope ontoscope = reg.getScope(iri);
>> >> -          Iterator<OWLOntology> importscope =
>> >> ontoscope.getCustomSpace().getOntologies().iterator();
>> >> -          Iterator<OntologySpace> importsession =
>> >> ontoscope.getSessionSpaces().iterator();
>> >> +                                       Iterator<OWLOntology> importscope
>> >> = ontoscope
>> >> +
>> >> .getCustomSpace().getOntologies().iterator();
>> >> +                                       Iterator<OntologySpace>
>> >> importsession = ontoscope
>> >> +
>> >> .getSessionSpaces().iterator();
>> >>
>> >> -          //Add ontology as import form scope, if it is anonymus we try
>> >> to add single axioms.
>> >> +                                       // Add ontology as import form
>> >> scope, if it is anonymus we
>> >> +                                       // try to add single axioms.
>> >>            while(importscope.hasNext()){
>> >>              OWLOntology auxonto = importscope.next();
>> >>              if(!auxonto.getOntologyID().isAnonymous()){
>> >> -            additions.add(new AddImport(inputowl,
>> >> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                                       additions.add(new
>> >> AddImport(inputowl, factory
>> >> +
>> >> .getOWLImportsDeclaration(auxonto
>> >> +
>> >>               .getOWLOntologyManager()
>> >> +
>> >>               .getOntologyDocumentIRI(auxonto))));
>> >>              }else{
>> >>                  mgr.addAxioms(inputowl,auxonto.getAxioms());
>> >>              }
>> >> @@ -204,11 +288,19 @@ public class Classify {
>> >>
>> >>           //Add ontology form sessions
>> >>           while(importsession.hasNext()){
>> >> -             Iterator<OWLOntology> sessionontos =
>> >> importsession.next().getOntologies().iterator();
>> >> +                                               Iterator<OWLOntology>
>> >> sessionontos = importsession
>> >> +
>> >> .next().getOntologies().iterator();
>> >>               while(sessionontos.hasNext()){
>> >>                  OWLOntology auxonto = sessionontos.next();
>> >>                  if(!auxonto.getOntologyID().isAnonymous()){
>> >> -                    additions.add(new AddImport(inputowl,
>> >> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                                               additions
>> >> +
>> >>       .add(new AddImport(
>> >> +
>> >>                       inputowl,
>> >> +
>> >>                       factory
>> >> +
>> >>                                       .getOWLImportsDeclaration(auxonto
>> >> +
>> >>
>> >> .getOWLOntologyManager()
>> >> +
>> >>
>> >> .getOntologyDocumentIRI(
>> >> +
>> >>
>> >> auxonto))));
>> >>                  }else{
>> >>                      mgr.addAxioms(inputowl,auxonto.getAxioms());
>> >>                  }
>> >> @@ -226,30 +318,38 @@ public class Classify {
>> >>        if((session!=null)&&(scope!=null))
>> >>        try{
>> >>            IRI iri = IRI.create(scope);
>> >> -          ScopeRegistry reg = ONManager.get().getScopeRegistry();
>> >> +                                       ScopeRegistry reg =
>> >> onm.getScopeRegistry();
>> >>            OntologyScope ontoscope = reg.getScope(iri);
>> >> -          SessionOntologySpace sos =
>> >> ontoscope.getSessionSpace(IRI.create(session));
>> >> +                                       SessionOntologySpace sos =
>> >> ontoscope.getSessionSpace(IRI
>> >> +
>> >> .create(session));
>> >>
>> >> -          Set<OWLOntology> ontos =
>> >> sos.getOntologyManager().getOntologies();
>> >> +                                       Set<OWLOntology> ontos =
>> >> sos.getOntologyManager()
>> >> +                                                       .getOntologies();
>> >>            Iterator<OWLOntology> iteronto = ontos.iterator();
>> >>
>> >> -          //Add session ontologies as import, if it is anonymus we try
>> >> to add single axioms.
>> >> +                                       // Add session ontologies as
>> >> import, if it is anonymus we
>> >> +                                       // try to add single axioms.
>> >>            while(iteronto.hasNext()){
>> >>              OWLOntology auxonto = iteronto.next();
>> >>              if(!auxonto.getOntologyID().isAnonymous()){
>> >> -                additions.add(new AddImport(inputowl,
>> >> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
>> >> +                                                       additions.add(new
>> >> AddImport(inputowl, factory
>> >> +
>> >> .getOWLImportsDeclaration(auxonto
>> >> +
>> >>               .getOWLOntologyManager()
>> >> +
>> >>               .getOntologyDocumentIRI(auxonto))));
>> >>              }else{
>> >>                  mgr.addAxioms(inputowl,auxonto.getAxioms());
>> >>              }
>> >>            }
>> >>
>> >>        }catch(Exception e){
>> >> -          System.err.println("ERROR: Problem with session: "+session);
>> >> +                                       System.err.println("ERROR:
>> >> Problem with session: "
>> >> +                                                       + session);
>> >>            e.printStackTrace();
>> >>            Response.status(Status.NOT_FOUND).build();
>> >>        }
>> >>
>> >> -      //After gathered the all ontology as imported now we apply the
>> >> changes
>> >> +                       // After gathered the all ontology as imported
>> >> now we apply the
>> >> +                       // changes
>> >>        if(additions.size()>0)
>> >>          mgr.applyChanges(additions);
>> >>
>> >> @@ -258,23 +358,35 @@ public class Classify {
>> >>
>> >>         try{
>> >>         if(recipe!=null) {
>> >> -            OWLOntology recipeowl =
>> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(recipe));
>> >> -            //Get Jea RDF model of SWRL rule contained in the recipe
>> >> +                                               OWLOntology recipeowl =
>> >> OWLManager
>> >> +
>> >> .createOWLOntologyManager()
>> >> +
>> >> .loadOntologyFromOntologyDocument(
>> >> +
>> >>       IRI.create(recipe));
>> >> +                                               // Get Jea RDF model of
>> >> SWRL rule contained in the
>> >> +                                               // recipe
>> >>              Model swrlmodel = fromRecipeToModel(recipeowl);
>> >>
>> >> -            //Create a reasoner to run rules contained in the recipe
>> >> -            KReSRunRules rulereasoner = new
>> >> KReSRunRules(swrlmodel,inputowl);
>> >> -            //Run the rule reasoner to the input RDF with the added
>> >> top-ontology
>> >> +                                               // Create a reasoner to
>> >> run rules contained in the
>> >> +                                               // recipe
>> >> +                                               KReSRunRules rulereasoner
>> >> = new KReSRunRules(swrlmodel,
>> >> +
>> >> inputowl);
>> >> +                                               // Run the rule reasoner
>> >> to the input RDF with the added
>> >> +                                               // top-ontology
>> >>              inputowl = rulereasoner.runRulesReasoner();
>> >>         }
>> >>
>> >>              //Create the reasoner for the classification
>> >> -            KReSCreateReasoner newreasoner = new
>> >> KReSCreateReasoner(inputowl);
>> >> -            //Prepare and start the reasoner to classify ontology's
>> >> resources
>> >> -            KReSRunReasoner reasoner = new
>> >> KReSRunReasoner(newreasoner.getReasoner());
>> >> -
>> >> -            //Create a new OWLOntology model where to put the inferred
>> >> axioms
>> >> -            OWLOntology output =
>> >> OWLManager.createOWLOntologyManager().createOntology(inputowl.getOntologyID());
>> >> +                                       KReSCreateReasoner newreasoner =
>> >> new KReSCreateReasoner(
>> >> +                                                       inputowl);
>> >> +                                       // Prepare and start the reasoner
>> >> to classify ontology's
>> >> +                                       // resources
>> >> +                                       KReSRunReasoner reasoner = new
>> >> KReSRunReasoner(newreasoner
>> >> +                                                       .getReasoner());
>> >> +
>> >> +                                       // Create a new OWLOntology model
>> >> where to put the inferred
>> >> +                                       // axioms
>> >> +                                       OWLOntology output =
>> >> OWLManager.createOWLOntologyManager()
>> >> +
>> >> .createOntology(inputowl.getOntologyID());
>> >>              //Initial input axioms count
>> >>              int startax = output.getAxiomCount();
>> >>              //Run the classification
>> >> @@ -295,26 +407,40 @@ public class Classi



-- 
Enrico Daga
Technology Expert
--
Ufficio Sistemi Informativi  (DCSPI-USI)
National Research Council (CNR)
P.le Aldo Moro 7 - Rome, Italy
Tel +39 4993 3321
--
Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC-CNR)
Via Nomentana 56, Rome - Italy
--
http://stlab.istc.cnr.it/stlab/User:EnricoDaga
http://www.enridaga.net
skype: enri-pan

Re: svn commit: r1053689 [1/6] - in /incubator/stanbol/trunk/kres: eu.iksproject.kres.api/ eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/ eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/ eu.

Posted by Upayavira <uv...@odoko.co.uk>.
I'm not objecting to anything in the commits per se, just saying, if you
need to do line endings, etc, do them as a commit that is *just* line
endings, and then another commit containing substantial changes.

That assists others in tracking changes - they can review the changes
you made as a result of STANBOL-10 as a hopefully small commit message.

Separating these changes into two commits just leaves a much clearer
audit trail behind.

Clearer?

Thanks, Upayavira

On Wed, 29 Dec 2010 19:20 +0100, "Enrico Daga" <en...@gmail.com>
wrote:
> The tidying was needed, elsewhere the patch posted in STANBOL-10 would
> not be accepted by SVN.
> This is why I did the conversion of line endings.
> The changes have been commented in the related issue.
> 
> Please tell me if I misunderstood something.
> Enrico
> 
> On 29 December 2010 19:12, Upayavira <uv...@odoko.co.uk> wrote:
> > Please keep 'code tidying' commits and actual code change commits
> > separate, otherwise it can be difficult to review the changes - e.g.
> > what of this commit is actual change?
> >
> > Thanks,
> >
> > Upaayvira
> >
> >
> > On Wed, 29 Dec 2010 18:04 +0000, enridaga@apache.org wrote:
> >> Author: enridaga
> >> Date: Wed Dec 29 18:04:19 2010
> >> New Revision: 1053689
> >>
> >> URL: http://svn.apache.org/viewvc?rev=1053689&view=rev
> >> Log:
> >> STANBOL-10
> >> Applying patch posted by Alessandro Adamou.
> >> Before that, applied a conversion for consistent line ending.
> >>
> >> Added:
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/resources/META-INF/conf/catalog.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/KReSConf/
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/KReSConf/rmi_config.owl
> >> Modified:
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Enrichment.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMOntResource.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMRootResource.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMScopeOntologyResource.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/resource/ONMScopeResource.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/Activator.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ONManager.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/io/OntologyRegistryIRISource.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/AbstractOntologySpaceImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/CoreOntologySpaceImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/CustomOntologySpaceImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyIndexImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyScopeFactoryImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologyScopeImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/OntologySpaceFactoryImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/ontology/SessionOntologySpaceImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/registry/model/impl/RegistryLoader.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/session/KReSSessionManagerImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/session/ScopeSessionSynchronizer.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/eu/iksproject/kres/manager/util/OntologyUtils.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/main/java/org/stlab/xd/utils/RDFSLabelGetter.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/Namespace.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestIndexing.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestOntologyScope.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/ontology/TestOntologySpaces.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/registry/TestRegistry.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.manager/src/test/java/eu/iksproject/kres/manager/session/TestSessions.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.ontologies/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.reasoners/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.reasoners/src/main/java/eu/iksproject/kres/reasoners/KReSReasonerImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSAddRecipe.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSRuleStore.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/java/eu/iksproject/kres/rules/manager/KReSSetRuleStore.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/main/resources/RuleOntology/rmi_config.owl
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSAddRecipeTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSAddRuleTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSGetRecipeTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSGetRuleTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSLoadRuleFileTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRemoveRecipeTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRemoveRuleTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.rules/src/test/java/eu/iksproject/kres/rules/manager/KReSRuleStoreTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.manager/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.manager/src/main/java/eu/iksproject/kres/semion/manager/SemionManagerImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/main/java/eu/iksproject/kres/semion/reengineer/db/DBExtractor.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.db/src/test/java/eu/iksproject/kres/semion/reengineer/db/DBExtractorTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/main/java/eu/iksproject/kres/semion/reengineer/xml/XMLExtractor.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.reengineer.xml/src/test/java/eu/iksproject/kres/semion/reengineer/xml/XMLReengineerTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/hermit124/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/mysql/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/owlapi3/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/owllink102/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/dependency/xerces/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.shared/transformation/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage.provider/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage.provider/src/main/java/eu/iksproject/kres/storage/provider/OntologyStorageProviderImpl.java
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage/pom.xml
> >>     incubator/stanbol/trunk/kres/eu.iksproject.kres.storage/src/main/java/eu/iksproject/kres/storage/ClerezzaStorage.java
> >>
> >> Modified: incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> --- incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml
> >> (original)
> >> +++ incubator/stanbol/trunk/kres/eu.iksproject.kres.api/pom.xml Wed Dec
> >> 29 18:04:19 2010
> >> @@ -7,14 +7,14 @@
> >>       <parent>
> >>               <groupId>eu.iksproject</groupId>
> >>               <artifactId>eu.iksproject.kres.parent</artifactId>
> >> -               <version>0.6-SNAPSHOT</version>
> >> +               <version>0.7</version>
> >>               <relativePath>../parent/pom.xml</relativePath>
> >>       </parent>
> >>
> >>       <groupId>eu.iksproject</groupId>
> >>       <artifactId>eu.iksproject.kres.api</artifactId>
> >>       <packaging>bundle</packaging>
> >> -       <version>0.6-SNAPSHOT</version>
> >> +       <version>${kres-version}</version>
> >>
> >>       <name>IKS KReS API</name>
> >>       <description>KReS API</description>
> >> @@ -23,7 +23,7 @@
> >>
> >>       <properties>
> >>               <jersey-version>1.1.5.1</jersey-version>
> >> -               <kres-version>0.6-SNAPSHOT</kres-version>
> >> +               <kres-version>0.7</kres-version>
> >>               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >>       </properties>
> >>
> >> @@ -36,7 +36,7 @@
> >>                               <configuration>
> >>                                       <instructions>
> >>                                               <Export-Package>
> >> -
> >> eu.iksproject.kres.api.*;version=${pom.version},
> >> +
> >> eu.iksproject.kres.api.*;version=${kres-version},
> >>                                                       com.hp.hpl.jena.*,
> >>                                                       com.ibm.icu.*,
> >>                                                       com.sun.jersey.*,
> >>
> >> Added:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java?rev=1053689&view=auto
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
> >> (added)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/ontology/SpaceType.java
> >> Wed Dec 29 18:04:19 2010
> >> @@ -0,0 +1,17 @@
> >> +package eu.iksproject.kres.api.manager.ontology;
> >> +
> >> +public enum SpaceType {
> >> +
> >> +       CORE("core"), CUSTOM("custom"), SESSION("session");
> >> +
> >> +       private SpaceType(String suffix) {
> >> +               this.suffix = suffix;
> >> +       }
> >> +
> >> +       private String suffix;
> >> +
> >> +       public String getIRISuffix() {
> >> +               return suffix;
> >> +       }
> >> +
> >> +}
> >>
> >> Modified:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
> >> (original)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.api/src/main/java/eu/iksproject/kres/api/manager/registry/KReSRegistryLoader.java
> >> Wed Dec 29 18:04:19 2010
> >> @@ -26,7 +26,7 @@ public interface KReSRegistryLoader {
> >>
> >>       public boolean hasLibrary(Registry reg, IRI libraryID);
> >>
> >> -       public boolean isPrintingLoadedOntologies();
> >> +//     public boolean isPrintingLoadedOntologies();
> >>
> >>       public void loadLocations() throws RegistryContentException;
> >>
> >> @@ -40,5 +40,5 @@ public interface KReSRegistryLoader {
> >>        */
> >>       public Set<Registry> loadRegistriesEager(IRI physicalIRI);
> >>
> >> -       public void setPrintLoadedOntologies(boolean doPrint);
> >> +//     public void setPrintLoadedOntologies(boolean doPrint);
> >>  }
> >>
> >> Added:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl?rev=1053689&view=auto
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
> >> (added)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/KReSConf/rmi_config.owl
> >> Wed Dec 29 18:04:19 2010
> >> @@ -0,0 +1,174 @@
> >> +<?xml version="1.0"?>
> >> +<rdf:RDF
> >> xmlns="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#"
> >> +     xml:base="http://kres.iks-project.eu/ontology/meta/rmi_config.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_config.owl">
> >> +        <owl:imports
> >> rdf:resource="http://ontologydesignpatterns.org/ont/iks/kres/rmi.owl"/>
> >> +    </owl:Ontology>
> >> +
> >> +
> >> +
> >> +    <!--
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +    //
> >> +    // Object Properties
> >> +    //
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +     -->
> >> +
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith -->
> >> +
> >> +    <owl:ObjectProperty
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#endWith"/>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule -->
> >> +
> >> +    <owl:ObjectProperty
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"/>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith -->
> >> +
> >> +    <owl:ObjectProperty
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#startWith"/>
> >> +
> >> +
> >> +
> >> +    <!--
> >> http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes
> >> -->
> >> +
> >> +    <owl:ObjectProperty
> >> rdf:about="http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes"/>
> >> +
> >> +
> >> +
> >> +    <!--
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +    //
> >> +    // Data properties
> >> +    //
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +     -->
> >> +
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead
> >> -->
> >> +
> >> +    <owl:DatatypeProperty
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"/>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription
> >> -->
> >> +
> >> +    <owl:DatatypeProperty
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasDescription"/>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence
> >> -->
> >> +
> >> +    <owl:DatatypeProperty
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#hasSequence"/>
> >> +
> >> +
> >> +
> >> +    <!--
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +    //
> >> +    // Classes
> >> +    //
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +     -->
> >> +
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule -->
> >> +
> >> +    <owl:Class
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe -->
> >> +
> >> +    <owl:Class
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
> >> +
> >> +
> >> +
> >> +    <!--
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +    //
> >> +    // Individuals
> >> +    //
> >> +
> >> ///////////////////////////////////////////////////////////////////////////////////////
> >> +     -->
> >> +
> >> +
> >> +
> >> +
> >> +    <!--
> >> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA -->
> >> +
> >> +    <owl:NamedIndividual
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA">
> >> +        <rdf:type
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
> >> +        <rmi:hasDescription
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Some description
> >> here</rmi:hasDescription>
> >> +        <rmi:hasSequence
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://eu.iksproject.kres/KReSOntologyRules.owl#MyRuleB,http://eu.iksproject.kres/KReSOntologyRules.owl#MyRuleA</rmi:hasSequence>
> >> +        <rmi:hasRule
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
> >> +        <rmi:endWith
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
> >> +        <rmi:hasRule
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB"/>
> >> +        <rmi:startWith
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB"/>
> >> +    </owl:NamedIndividual>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA
> >> -->
> >> +
> >> +    <owl:NamedIndividual
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA">
> >> +        <rdf:type
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
> >> +        <rmi:hasDescription
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example of
> >> description for my rule A</rmi:hasDescription>
> >> +        <rmi:hasBodyAndHead
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BodyA -&gt;
> >> BodyB</rmi:hasBodyAndHead>
> >> +    </owl:NamedIndividual>
> >> +
> >> +
> >> +
> >> +    <!-- http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB
> >> -->
> >> +
> >> +    <owl:NamedIndividual
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleB">
> >> +        <rdf:type
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
> >> +        <rmi:hasDescription
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example of
> >> description..for my rule B</rmi:hasDescription>
> >> +        <rmi:hasBodyAndHead
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BodyB -&gt;
> >> HeadB</rmi:hasBodyAndHead>
> >> +        <sequence:directlyPrecedes
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRuleA"/>
> >> +    </owl:NamedIndividual>
> >> +
> >> +
> >> +
> >> +    <!--
> >> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRecipe
> >> -->
> >> +
> >> +    <owl:NamedIndividual
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRecipe">
> >> +        <rdf:type
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"/>
> >> +        <rmi:hasDescription
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A single rule
> >> recipe.</rmi:hasDescription>
> >> +        <rmi:hasSequence
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule</rmi:hasSequence>
> >> +        <rmi:endWith
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
> >> +        <rmi:hasRule
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
> >> +        <rmi:startWith
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule"/>
> >> +    </owl:NamedIndividual>
> >> +
> >> +
> >> +
> >> +    <!--
> >> http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule
> >> -->
> >> +
> >> +    <owl:NamedIndividual
> >> rdf:about="http://kres.iks-project.eu/ontology/meta/rmi_config.owl#ProvaParentRule">
> >> +        <rdf:type
> >> rdf:resource="http://kres.iks-project.eu/ontology/meta/rmi.owl#KReSRule"/>
> >> +        <rmi:hasDescription
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A rule to
> >> inference if a person has an uncle.</rmi:hasDescription>
> >> +        <rmi:hasBodyAndHead
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ProvaParent =
> >> &lt;http://www.semanticweb.org/ontologies/2010/6/ProvaParent.owl#&gt; .
> >> rule1[ has(ProvaParent:hasParent, ?x, ?y) . has(ProvaParent:hasBrother,
> >> ?y, ?z) -&gt; has(ProvaParent:hasUncle, ?x, ?z) ]</rmi:hasBodyAndHead>
> >> +    </owl:NamedIndividual>
> >> +</rdf:RDF>
> >> +
> >> +
> >> +
> >> +<!-- Generated by the OWL API (version 3.0.0.1413)
> >> http://owlapi.sourceforge.net -->
> >> +
> >>
> >> Modified: incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> --- incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml
> >> (original)
> >> +++ incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/pom.xml Wed
> >> Dec 29 18:04:19 2010
> >> @@ -7,13 +7,13 @@
> >>       <parent>
> >>               <groupId>eu.iksproject</groupId>
> >>               <artifactId>eu.iksproject.kres.parent</artifactId>
> >> -               <version>0.6-SNAPSHOT</version>
> >> +               <version>0.7</version>
> >>               <relativePath>../parent/pom.xml</relativePath>
> >>       </parent>
> >>
> >>       <groupId>eu.iksproject</groupId>
> >>       <artifactId>eu.iksproject.kres.jersey</artifactId>
> >> -       <version>0.6-SNAPSHOT</version>
> >> +       <version>${kres-version}</version>
> >>       <packaging>bundle</packaging>
> >>
> >>       <name>IKS KReS Jersey JAX-RS API and front-end</name>
> >> @@ -22,7 +22,8 @@
> >>       <properties>
> >>               <jersey-version>1.1.5.1</jersey-version>
> >>               <pax-exam-version>1.2.0</pax-exam-version>
> >> -               <kres-version>0.6-SNAPSHOT</kres-version>
> >> +               <kres-version>0.7</kres-version>
> >> +
> >> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> >>       </properties>
> >>
> >>       <dependencies>
> >> @@ -252,6 +253,12 @@
> >>              <scope>provided</scope>
> >>           </dependency>
> >>               <dependency>
> >> +                       <groupId>eu.iksproject</groupId>
> >> +
> >> <artifactId>eu.iksproject.kres.storage.provider</artifactId>
> >> +                       <version>${kres-version}</version>
> >> +                       <scope>provided</scope>
> >> +               </dependency>
> >> +               <dependency>
> >>                       <groupId>com.hp.hpl.jena</groupId>
> >>                       <artifactId>jena</artifactId>
> >>                       <version>2.6.2</version>
> >>
> >> Modified:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
> >> (original)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Recipe.java
> >> Wed Dec 29 18:04:19 2010
> >> @@ -5,19 +5,14 @@
> >>
> >>  package eu.iksproject.kres.jersey.manager;
> >>
> >> -import eu.iksproject.kres.api.rules.RuleStore;
> >> -import eu.iksproject.kres.jersey.resource.NavigationMixin;
> >> -import eu.iksproject.kres.rules.manager.KReSAddRecipe;
> >> -import eu.iksproject.kres.rules.manager.KReSGetRecipe;
> >> -import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
> >> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >> -import eu.iksproject.kres.api.format.KReSFormat;
> >>  import java.util.HashMap;
> >> +import java.util.Hashtable;
> >>  import java.util.Iterator;
> >>  import java.util.LinkedList;
> >>  import java.util.List;
> >>  import java.util.Set;
> >>  import java.util.Vector;
> >> +
> >>  import javax.servlet.ServletContext;
> >>  import javax.ws.rs.Consumes;
> >>  import javax.ws.rs.DELETE;
> >> @@ -33,8 +28,8 @@ import javax.ws.rs.core.Context;
> >>  import javax.ws.rs.core.MediaType;
> >>  import javax.ws.rs.core.Response;
> >>  import javax.ws.rs.core.Response.Status;
> >> +
> >>  import org.semanticweb.owlapi.apibinding.OWLManager;
> >> -import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
> >>  import org.semanticweb.owlapi.model.AddImport;
> >>  import org.semanticweb.owlapi.model.IRI;
> >>  import org.semanticweb.owlapi.model.OWLDataFactory;
> >> @@ -45,59 +40,102 @@ import org.semanticweb.owlapi.model.OWLO
> >>  import org.semanticweb.owlapi.model.OWLOntology;
> >>  import org.semanticweb.owlapi.model.OWLOntologyChange;
> >>  import org.semanticweb.owlapi.model.OWLOntologyStorageException;
> >> +import org.slf4j.Logger;
> >> +import org.slf4j.LoggerFactory;
> >>
> >> -import com.sun.jersey.api.view.ImplicitProduces;
> >> +import eu.iksproject.kres.api.format.KReSFormat;
> >> +import eu.iksproject.kres.api.manager.KReSONManager;
> >> +import eu.iksproject.kres.api.rules.RuleStore;
> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
> >> +import eu.iksproject.kres.jersey.resource.NavigationMixin;
> >> +import eu.iksproject.kres.manager.ONManager;
> >> +import eu.iksproject.kres.rules.manager.KReSAddRecipe;
> >> +import eu.iksproject.kres.rules.manager.KReSGetRecipe;
> >> +import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
> >> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
> >>
> >>  /**
> >>   *
> >>   * @author elvio
> >>   */
> >> -@Path("/recipe")///{uri:.+}")
> >> +@Path("/recipe")
> >> +// /{uri:.+}")
> >>  //@ImplicitProduces(MediaType.TEXT_HTML + ";qs=2")
> >>  public class Recipe extends NavigationMixin{
> >>
> >> +       protected KReSONManager onm;
> >> +
> >> +       private Logger log = LoggerFactory.getLogger(getClass());
> >> +
> >>      private RuleStore kresRuleStore;
> >> +       private OntologyStoreProvider storeProvider;
> >>
> >>     /**
> >>       * To get the KReSRuleStore where are stored the rules and the
> >>       recipes
> >>       *
> >> -     * @param servletContext {To get the context where the REST service
> >> is running.}
> >> +        * @param servletContext
> >> +        *            {To get the context where the REST service is
> >> running.}
> >>       */
> >>      public Recipe(@Context ServletContext servletContext){
> >> -       this.kresRuleStore = (RuleStore)
> >> servletContext.getAttribute(RuleStore.class.getName());
> >> +               this.kresRuleStore = (RuleStore) servletContext
> >> +                               .getAttribute(RuleStore.class.getName());
> >> +               this.onm = (KReSONManager) servletContext
> >> +
> >> .getAttribute(KReSONManager.class.getName());
> >> +               this.storeProvider = (OntologyStoreProvider)
> >> servletContext
> >> +
> >> .getAttribute(OntologyStoreProvider.class.getName());
> >> +               // Contingency code for missing components follows.
> >> +               /*
> >> +                * FIXME! The following code is required only for the
> >> tests. This should
> >> +                * be removed and the test should work without this code.
> >> +                */
> >> +               if (storeProvider == null) {
> >> +                       log
> >> +                                       .warn("No OntologyStoreProvider
> >> in servlet context. Instantiating manually...");
> >> +                       storeProvider = new
> >> OntologyStorageProviderImpl();
> >> +               }
> >> +               if (onm == null) {
> >> +                       log
> >> +                                       .warn("No KReSONManager in
> >> servlet context. Instantiating manually...");
> >> +                       onm = new
> >> ONManager(storeProvider.getActiveOntologyStorage(),
> >> +                                       new Hashtable<String, Object>());
> >> +               }
> >>         if (kresRuleStore == null) {
> >> -           System.err.println("WARNING: KReSRuleStore with stored rules
> >> and recipes is missing in ServletContext. A new instance has been
> >> created.");
> >> -           this.kresRuleStore = new KReSRuleStore("");
> >> -           System.err.println("PATH TO OWL FILE LOADED:
> >> "+kresRuleStore.getFilePath());
> >> -            /*throw new IllegalStateException(
> >> -                    "KReSRuleStore with stored rules and recipes is
> >> missing in ServletContext");*/
> >> +                       log
> >> +                                       .warn("No KReSRuleStore with
> >> stored rules and recipes found in servlet context. Instantiating manually
> >> with default values...");
> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
> >> +                                       new Hashtable<String, Object>(),
> >> "");
> >> +                       log
> >> +                                       .debug("PATH TO OWL FILE LOADED:
> >> "
> >> +                                                       +
> >> kresRuleStore.getFilePath());
> >>          }
> >>      }
> >>
> >>     /**
> >> -     * Get a recipe with its rules from the rule base (that is the
> >> ontology that contains the rules and the recipe).
> >> +        * Get a recipe with its rules from the rule base (that is the
> >> ontology that
> >> +        * contains the rules and the recipe).
> >>       *
> >> -     * @param uri {A string contains the IRI full name of the recipe.}
> >> +        * @param uri
> >> +        *            {A string contains the IRI full name of the
> >> recipe.}
> >>       * @return Return: <br/>
> >> -     *       200 The recipe is retrieved (import declarations point to
> >> KReS Services) <br/>
> >> +        *         200 The recipe is retrieved (import declarations point
> >> to KReS
> >> +        *         Services) <br/>
> >>       *       404 The recipe does not exists in the manager <br/>
> >>       *       500 Some error occurred
> >>       *
> >>       */
> >>      @GET
> >>      @Path("/{uri:.+}")
> >> -    @Produces(value={KReSFormat.RDF_XML,
> >> -                                KReSFormat.TURTLE,
> >> -                                KReSFormat.OWL_XML,
> >> -                                KReSFormat.FUNCTIONAL_OWL,
> >> -                                KReSFormat.MANCHESTER_OWL,
> >> -                                KReSFormat.RDF_JSON})
> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
> >> +                       KReSFormat.OWL_XML, KReSFormat.FUNCTIONAL_OWL,
> >> +                       KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON })
> >>      public Response getRecipe(@PathParam("uri") String uri){
> >>        try{
> >>
> >>         KReSGetRecipe rule = new KReSGetRecipe(kresRuleStore);
> >>
> >> -       //String ID =
> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
> >> +                       // String ID =
> >> +                       //
> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
> >>
> >>         if(uri.equals("all")){
> >>
> >> @@ -108,32 +146,48 @@ public class Recipe extends NavigationMi
> >>              return Response.status(Status.NOT_FOUND).build();
> >>          }else{
> >>
> >> -            //The recipe is retrieved (import declarations point to KReS
> >> Services)
> >> +                                       // The recipe is retrieved
> >> (import declarations point to
> >> +                                       // KReS Services)
> >>              OWLOntology onto = kresRuleStore.getOntology();
> >> -            OWLOntology newmodel =
> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
> >> -            OWLDataFactory factory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> +                                       OWLOntology newmodel = OWLManager
> >> +
> >> .createOWLOntologyManager().createOntology(
> >> +
> >> onto.getOntologyID());
> >> +                                       OWLDataFactory factory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >>
> >> -            Iterator<OWLOntology> importedonto =
> >> onto.getDirectImports().iterator();
> >> +                                       Iterator<OWLOntology>
> >> importedonto = onto
> >> +
> >> .getDirectImports().iterator();
> >>              List<OWLOntologyChange> additions = new
> >>              LinkedList<OWLOntologyChange>();
> >> -            OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> +                                       OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >>
> >>              while(importedonto.hasNext()){
> >>                  OWLOntology auxonto = importedonto.next();
> >> -                additions.add(new
> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                               additions.add(new
> >> AddImport(newmodel, auxfactory
> >> +
> >> .getOWLImportsDeclaration(auxonto
> >> +
> >>       .getOWLOntologyManager()
> >> +
> >>       .getOntologyDocumentIRI(auxonto))));
> >>              }
> >>
> >>              if(!additions.isEmpty())
> >> -
> >> newmodel.getOWLOntologyManager().applyChanges(additions);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .applyChanges(additions);
> >>
> >>              for(int i = 0; i<recipe.size(); i++){
> >> -                OWLNamedIndividual ind =
> >> factory.getOWLNamedIndividual(recipe.get(i));
> >> +                                               OWLNamedIndividual ind =
> >> factory
> >> +
> >> .getOWLNamedIndividual(recipe.get(i));
> >>                  Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
> >> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .addAxioms(newmodel, ax);
> >>
> >>              }
> >>
> >>              try {
> >> -
> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
> >> System.out);
> >> +
> >> OWLManager.createOWLOntologyManager().saveOntology(
> >> +                                                               newmodel,
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >>       .getOntologyFormat(newmodel),
> >> +
> >> System.out);
> >>               } catch (OWLOntologyStorageException e) {
> >>                       // TODO Auto-generated catch block
> >>                       e.printStackTrace();
> >> @@ -150,30 +204,44 @@ public class Recipe extends NavigationMi
> >>              //The recipe deos not exists in the manager
> >>              return Response.status(Status.NOT_FOUND).build();
> >>          }else{
> >> -            //The recipe is retrieved (import declarations point to KReS
> >> Services)
> >> +                                       // The recipe is retrieved
> >> (import declarations point to
> >> +                                       // KReS Services)
> >>              OWLOntology onto = kresRuleStore.getOntology();
> >>
> >> -            OWLDataFactory factory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> -            OWLObjectProperty prop =
> >> factory.getOWLObjectProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
> >> -            OWLNamedIndividual ind =
> >> factory.getOWLNamedIndividual(IRI.create(uri));
> >> -            Set<OWLIndividual> value = ind.getObjectPropertyValues(prop,
> >> onto);
> >> +                                       OWLDataFactory factory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >> +                                       OWLObjectProperty prop = factory
> >> +
> >> .getOWLObjectProperty(IRI
> >> +
> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
> >> +                                       OWLNamedIndividual ind =
> >> factory.getOWLNamedIndividual(IRI
> >> +                                                       .create(uri));
> >> +                                       Set<OWLIndividual> value =
> >> ind.getObjectPropertyValues(
> >> +                                                       prop, onto);
> >>              Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
> >>
> >>              Iterator<OWLIndividual> iter = value.iterator();
> >>
> >> -            OWLOntology newmodel =
> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
> >> +                                       OWLOntology newmodel = OWLManager
> >> +
> >> .createOWLOntologyManager().createOntology(
> >> +
> >> onto.getOntologyID());
> >>
> >> -            Iterator<OWLOntology> importedonto =
> >> onto.getDirectImports().iterator();
> >> +                                       Iterator<OWLOntology>
> >> importedonto = onto
> >> +
> >> .getDirectImports().iterator();
> >>              List<OWLOntologyChange> additions = new
> >>              LinkedList<OWLOntologyChange>();
> >> -            OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> +                                       OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >>
> >>              while(importedonto.hasNext()){
> >>                  OWLOntology auxonto = importedonto.next();
> >> -                additions.add(new
> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                               additions.add(new
> >> AddImport(newmodel, auxfactory
> >> +
> >> .getOWLImportsDeclaration(auxonto
> >> +
> >>       .getOWLOntologyManager()
> >> +
> >>       .getOntologyDocumentIRI(auxonto))));
> >>              }
> >>
> >>              if(!additions.isEmpty())
> >> -
> >> newmodel.getOWLOntologyManager().applyChanges(additions);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .applyChanges(additions);
> >>
> >>              newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
> >>
> >> @@ -182,11 +250,16 @@ public class Recipe extends NavigationMi
> >>                  ind = (OWLNamedIndividual) iter.next();
> >>                  ax = onto.getAxioms(ind);
> >>
> >> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .addAxioms(newmodel, ax);
> >>              }
> >>
> >>              try {
> >> -
> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
> >> System.out);
> >> +
> >> OWLManager.createOWLOntologyManager().saveOntology(
> >> +                                                               newmodel,
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >>       .getOntologyFormat(newmodel),
> >> +
> >> System.out);
> >>               } catch (OWLOntologyStorageException e) {
> >>                       // TODO Auto-generated catch block
> >>                       e.printStackTrace();
> >> @@ -204,8 +277,11 @@ public class Recipe extends NavigationMi
> >>
> >>     /**
> >>       * To add a recipe without rules.
> >> -     * @param recipe {A string contains the IRI of the recipe to be
> >> added}
> >> -     * @param description {A string contains a description of the rule}
> >> +        *
> >> +        * @param recipe
> >> +        *            {A string contains the IRI of the recipe to be
> >> added}
> >> +        * @param description
> >> +        *            {A string contains a description of the rule}
> >>       * @return Return: <br/>
> >>       *      200 The recipe has been added<br/>
> >>       *      409 The recipe has not been added<br/>
> >> @@ -213,21 +289,21 @@ public class Recipe extends NavigationMi
> >>       */
> >>      @POST
> >>      @Consumes(MediaType.MULTIPART_FORM_DATA)
> >> -    @Produces(value={KReSFormat.RDF_XML,
> >> -                                KReSFormat.TURTLE,
> >> -                                KReSFormat.OWL_XML,
> >> -                                KReSFormat.FUNCTIONAL_OWL,
> >> -                                KReSFormat.MANCHESTER_OWL,
> >> -                                KReSFormat.RDF_JSON})
> >> -    public Response addRecipe(@FormParam(value="recipe") String
> >> recipe,@FormParam(value="description") String description){
> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
> >> +                       KReSFormat.OWL_XML, KReSFormat.FUNCTIONAL_OWL,
> >> +                       KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON })
> >> +       public Response addRecipe(@FormParam(value = "recipe") String
> >> recipe,
> >> +                       @FormParam(value = "description") String
> >> description) {
> >>
> >>          try{
> >>
> >>              KReSAddRecipe instance = new KReSAddRecipe(kresRuleStore);
> >>
> >> -            //String ID =
> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
> >> +                       // String ID =
> >> +                       //
> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
> >>
> >> -            boolean ok = instance.addSimpleRecipe(IRI.create(recipe),
> >> description);
> >> +                       boolean ok =
> >> instance.addSimpleRecipe(IRI.create(recipe),
> >> +                                       description);
> >>
> >>                  if(!ok){
> >>
> >> @@ -245,9 +321,10 @@ public class Recipe extends NavigationMi
> >>
> >>     /**
> >>       * To delete a recipe
> >> -     * @param recipe {A tring contains an IRI of the recipe}
> >> -     * @return
> >> -     *      200 The recipe has been deleted<br/>
> >> +        *
> >> +        * @param recipe
> >> +        *            {A tring contains an IRI of the recipe}
> >> +        * @return 200 The recipe has been deleted<br/>
> >>       *      409 The recipe has not been deleted<br/>
> >>       *      500 Some error occurred
> >>       */
> >> @@ -260,7 +337,8 @@ public class Recipe extends NavigationMi
> >>
> >>              KReSRemoveRecipe instance = new
> >>              KReSRemoveRecipe(kresRuleStore);
> >>
> >> -            //String ID =
> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
> >> +                       // String ID =
> >> +                       //
> >> kresRuleStore.getOntology().getOntologyID().toString().replace(">","").replace("<","")+"#";
> >>
> >>              boolean ok = instance.removeRecipe(IRI.create(recipe));
> >>
> >>
> >> Modified:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
> >> (original)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/manager/Rule.java
> >> Wed Dec 29 18:04:19 2010
> >> @@ -5,27 +5,16 @@
> >>
> >>  package eu.iksproject.kres.jersey.manager;
> >>
> >> -import eu.iksproject.kres.api.rules.RuleStore;
> >> -import eu.iksproject.kres.jersey.resource.NavigationMixin;
> >> -import eu.iksproject.kres.rules.manager.KReSAddRecipe;
> >> -import eu.iksproject.kres.rules.manager.KReSAddRule;
> >> -import eu.iksproject.kres.rules.manager.KReSGetRecipe;
> >> -import eu.iksproject.kres.rules.manager.KReSGetRule;
> >> -import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
> >> -import eu.iksproject.kres.rules.manager.KReSRemoveRule;
> >> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >> -import eu.iksproject.kres.api.format.KReSFormat;
> >> -
> >>  import java.io.UnsupportedEncodingException;
> >>  import java.net.URLEncoder;
> >> -import java.util.ArrayList;
> >> -import java.util.Collection;
> >>  import java.util.HashMap;
> >> +import java.util.Hashtable;
> >>  import java.util.Iterator;
> >>  import java.util.LinkedList;
> >>  import java.util.List;
> >>  import java.util.Set;
> >>  import java.util.Vector;
> >> +
> >>  import javax.servlet.ServletContext;
> >>  import javax.ws.rs.Consumes;
> >>  import javax.ws.rs.DELETE;
> >> @@ -42,24 +31,32 @@ import javax.ws.rs.core.MediaType;
> >>  import javax.ws.rs.core.Response;
> >>  import javax.ws.rs.core.Response.Status;
> >>
> >> -import org.codehaus.jettison.json.JSONArray;
> >>  import org.semanticweb.owlapi.apibinding.OWLManager;
> >> -import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
> >> -import org.semanticweb.owlapi.model.AddAxiom;
> >>  import org.semanticweb.owlapi.model.AddImport;
> >>  import org.semanticweb.owlapi.model.IRI;
> >> -import org.semanticweb.owlapi.model.OWLAxiom;
> >>  import org.semanticweb.owlapi.model.OWLDataFactory;
> >> -import org.semanticweb.owlapi.model.OWLIndividual;
> >>  import org.semanticweb.owlapi.model.OWLIndividualAxiom;
> >>  import org.semanticweb.owlapi.model.OWLNamedIndividual;
> >> -import org.semanticweb.owlapi.model.OWLObjectProperty;
> >> -import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
> >>  import org.semanticweb.owlapi.model.OWLOntology;
> >>  import org.semanticweb.owlapi.model.OWLOntologyChange;
> >> -import org.semanticweb.owlapi.model.OWLOntologyCreationException;
> >> -import org.semanticweb.owlapi.model.OWLOntologyManager;
> >>  import org.semanticweb.owlapi.model.OWLOntologyStorageException;
> >> +import org.slf4j.Logger;
> >> +import org.slf4j.LoggerFactory;
> >> +
> >> +import eu.iksproject.kres.api.format.KReSFormat;
> >> +import eu.iksproject.kres.api.manager.KReSONManager;
> >> +import eu.iksproject.kres.api.rules.RuleStore;
> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
> >> +import eu.iksproject.kres.jersey.resource.NavigationMixin;
> >> +import eu.iksproject.kres.manager.ONManager;
> >> +import eu.iksproject.kres.rules.manager.KReSAddRecipe;
> >> +import eu.iksproject.kres.rules.manager.KReSAddRule;
> >> +import eu.iksproject.kres.rules.manager.KReSGetRecipe;
> >> +import eu.iksproject.kres.rules.manager.KReSGetRule;
> >> +import eu.iksproject.kres.rules.manager.KReSRemoveRecipe;
> >> +import eu.iksproject.kres.rules.manager.KReSRemoveRule;
> >> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
> >>
> >>  /**
> >>   *
> >> @@ -70,40 +67,74 @@ import org.semanticweb.owlapi.model.OWLO
> >>  @Path("/rule")
> >>  public class Rule extends NavigationMixin{
> >>
> >> -    private static RuleStore kresRuleStore;
> >> +       protected KReSONManager onm;
> >> +       protected OntologyStoreProvider storeProvider;
> >> +
> >> +       private Logger log = LoggerFactory.getLogger(getClass());
> >> +
> >> +       private RuleStore kresRuleStore;
> >>      private HashMap<IRI, String> map;
> >>      private String desc;
> >>
> >>     /**
> >>       * To get the KReSRuleStore where are stored the rules and the
> >>       recipes
> >>       *
> >> -     * @param servletContext {To get the context where the REST service
> >> is running.}
> >> +        * @param servletContext
> >> +        *            {To get the context where the REST service is
> >> running.}
> >>       */
> >>      public Rule(@Context ServletContext servletContext){
> >> -       this.kresRuleStore = (RuleStore)
> >> servletContext.getAttribute(RuleStore.class.getName());
> >> -
> >> +               this.kresRuleStore = (RuleStore) servletContext
> >> +                               .getAttribute(RuleStore.class.getName());
> >> +               this.onm = (KReSONManager) servletContext
> >> +
> >> .getAttribute(KReSONManager.class.getName());
> >> +               this.storeProvider = (OntologyStoreProvider)
> >> servletContext
> >> +
> >> .getAttribute(OntologyStoreProvider.class.getName());
> >> +               // Contingency code for missing components follows.
> >> +               /*
> >> +                * FIXME! The following code is required only for the
> >> tests. This should
> >> +                * be removed and the test should work without this code.
> >> +                */
> >> +               if (storeProvider == null) {
> >> +                       log
> >> +                                       .warn("No OntologyStoreProvider
> >> in servlet context. Instantiating manually...");
> >> +                       storeProvider = new
> >> OntologyStorageProviderImpl();
> >> +               }
> >> +               if (onm == null) {
> >> +                       log
> >> +                                       .warn("No KReSONManager in
> >> servlet context. Instantiating manually...");
> >> +                       onm = new
> >> ONManager(storeProvider.getActiveOntologyStorage(),
> >> +                                       new Hashtable<String, Object>());
> >> +               }
> >>         if (kresRuleStore == null) {
> >> -           System.err.println("WARNING: KReSRuleStore with stored rules
> >> and recipes is missing in ServletContext. A new instance has been
> >> created.");
> >> -           this.kresRuleStore = new KReSRuleStore("");
> >> -           System.err.println("PATH TO OWL FILE LOADED:
> >> "+kresRuleStore.getFilePath());
> >> -            /*throw new IllegalStateException(
> >> -                    "KReSRuleStore with stored rules and recipes is
> >> missing in ServletContext");*/
> >> +                       log
> >> +                                       .warn("No KReSRuleStore with
> >> stored rules and recipes found in servlet context. Instantiating manually
> >> with default values...");
> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
> >> +                                       new Hashtable<String, Object>(),
> >> "");
> >> +                       log
> >> +                                       .debug("PATH TO OWL FILE LOADED:
> >> "
> >> +                                                       +
> >> kresRuleStore.getFilePath());
> >>          }
> >>      }
> >>
> >>     /**
> >> -     * Get a rule from the rule base (that is the ontology that contains
> >> the rules and the recipe).
> >> -     * curl -v -X GET
> >> http://localhost:8080/kres/rule/http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule
> >> -     * @param uri {A string contains the IRI full name of the rule.}
> >> +        * Get a rule from the rule base (that is the ontology that
> >> contains the
> >> +        * rules and the recipe). curl -v -X GET
> >> +        * http://localhost:8080/kres/rule/http
> >> +        * ://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRule
> >> +        *
> >> +        * @param uri
> >> +        *            {A string contains the IRI full name of the rule.}
> >>       * @return Return: <br/>
> >> -     *       200 The rule is retrieved (import declarations point to
> >> KReS Services) <br/>
> >> +        *         200 The rule is retrieved (import declarations point
> >> to KReS
> >> +        *         Services) <br/>
> >>       *       404 The rule does not exists in the manager <br/>
> >>       *       500 Some error occurred
> >>       *
> >>       */
> >>      @GET
> >>      @Path("/{uri:.+}")
> >> -
> >> @Produces(value={KReSFormat.RDF_XML,KReSFormat.TURTLE,KReSFormat.OWL_XML})
> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
> >> +                       KReSFormat.OWL_XML })
> >>      public Response getRule(@PathParam("uri") String uri){
> >>
> >>        try{
> >> @@ -119,29 +150,44 @@ public class Rule extends NavigationMixi
> >>          }else{
> >>
> >>              OWLOntology onto = kresRuleStore.getOntology();
> >> -            OWLOntology newmodel =
> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
> >> -            OWLDataFactory factory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> +                                       OWLOntology newmodel = OWLManager
> >> +
> >> .createOWLOntologyManager().createOntology(
> >> +
> >> onto.getOntologyID());
> >> +                                       OWLDataFactory factory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >>
> >> -            Iterator<OWLOntology> importedonto =
> >> onto.getDirectImports().iterator();
> >> +                                       Iterator<OWLOntology>
> >> importedonto = onto
> >> +
> >> .getDirectImports().iterator();
> >>              List<OWLOntologyChange> additions = new
> >>              LinkedList<OWLOntologyChange>();
> >> -            OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> +                                       OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >>
> >>              while(importedonto.hasNext()){
> >>                  OWLOntology auxonto = importedonto.next();
> >> -                additions.add(new
> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                               additions.add(new
> >> AddImport(newmodel, auxfactory
> >> +
> >> .getOWLImportsDeclaration(auxonto
> >> +
> >>       .getOWLOntologyManager()
> >> +
> >>       .getOntologyDocumentIRI(auxonto))));
> >>              }
> >>
> >>              if(!additions.isEmpty())
> >> -
> >> newmodel.getOWLOntologyManager().applyChanges(additions);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .applyChanges(additions);
> >>
> >>              while(keys.hasNext()){
> >> -                OWLNamedIndividual ind =
> >> factory.getOWLNamedIndividual(keys.next());
> >> +                                               OWLNamedIndividual ind =
> >> factory
> >> +
> >> .getOWLNamedIndividual(keys.next());
> >>                  Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
> >> -                newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .addAxioms(newmodel, ax);
> >>              }
> >>
> >>              try {
> >> -
> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
> >> System.out);
> >> +
> >> OWLManager.createOWLOntologyManager().saveOntology(
> >> +                                                               newmodel,
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >>       .getOntologyFormat(newmodel),
> >> +
> >> System.out);
> >>               } catch (OWLOntologyStorageException e) {
> >>                       // TODO Auto-generated catch block
> >>                       e.printStackTrace();
> >> @@ -159,27 +205,41 @@ public class Rule extends NavigationMixi
> >>          }else{
> >>              OWLOntology onto = kresRuleStore.getOntology();
> >>
> >> -            OWLDataFactory factory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> -            OWLNamedIndividual ind =
> >> factory.getOWLNamedIndividual(IRI.create(uri));
> >> +                                       OWLDataFactory factory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >> +                                       OWLNamedIndividual ind =
> >> factory.getOWLNamedIndividual(IRI
> >> +                                                       .create(uri));
> >>              Set<OWLIndividualAxiom> ax = onto.getAxioms(ind);
> >> -            OWLOntology newmodel =
> >> OWLManager.createOWLOntologyManager().createOntology(onto.getOntologyID());
> >> +                                       OWLOntology newmodel = OWLManager
> >> +
> >> .createOWLOntologyManager().createOntology(
> >> +
> >> onto.getOntologyID());
> >>
> >> -            Iterator<OWLOntology> importedonto =
> >> onto.getDirectImports().iterator();
> >> +                                       Iterator<OWLOntology>
> >> importedonto = onto
> >> +
> >> .getDirectImports().iterator();
> >>              List<OWLOntologyChange> additions = new
> >>              LinkedList<OWLOntologyChange>();
> >> -            OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager().getOWLDataFactory();
> >> +                                       OWLDataFactory auxfactory =
> >> onto.getOWLOntologyManager()
> >> +
> >> .getOWLDataFactory();
> >>
> >>              while(importedonto.hasNext()){
> >>                  OWLOntology auxonto = importedonto.next();
> >> -                additions.add(new
> >> AddImport(newmodel,auxfactory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                               additions.add(new
> >> AddImport(newmodel, auxfactory
> >> +
> >> .getOWLImportsDeclaration(auxonto
> >> +
> >>       .getOWLOntologyManager()
> >> +
> >>       .getOntologyDocumentIRI(auxonto))));
> >>              }
> >>
> >>              if(!additions.isEmpty())
> >> -
> >> newmodel.getOWLOntologyManager().applyChanges(additions);
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >> .applyChanges(additions);
> >>
> >>              newmodel.getOWLOntologyManager().addAxioms(newmodel,ax);
> >>
> >>              try {
> >> -
> >> OWLManager.createOWLOntologyManager().saveOntology(newmodel,
> >> newmodel.getOWLOntologyManager().getOntologyFormat(newmodel),
> >> System.out);
> >> +
> >> OWLManager.createOWLOntologyManager().saveOntology(
> >> +                                                               newmodel,
> >> +
> >> newmodel.getOWLOntologyManager()
> >> +
> >>       .getOntologyFormat(newmodel),
> >> +
> >> System.out);
> >>               } catch (OWLOntologyStorageException e) {
> >>                       // TODO Auto-generated catch block
> >>                       e.printStackTrace();
> >> @@ -197,15 +257,16 @@ public class Rule extends NavigationMixi
> >>
> >>      @GET
> >>      @Path("/of-recipe/{uri:.+}")
> >> -    @Produces(value={KReSFormat.RDF_XML,
> >> -                                KReSFormat.RDF_JSON})
> >> -
> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.RDF_JSON })
> >>      public Response getRulesOfRecipe(@PathParam("uri") String
> >>      recipeURI){
> >>
> >>       KReSGetRule kReSGetRule = new KReSGetRule(kresRuleStore);
> >>       String recipeURIEnc;
> >>               try {
> >> -                       recipeURIEnc =
> >> URLEncoder.encode("http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA",
> >> "UTF-8");
> >> +                       recipeURIEnc = URLEncoder
> >> +                                       .encode(
> >> +
> >> "http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyRecipeA",
> >> +                                                       "UTF-8");
> >>                       System.out.println("RECIPE : "+recipeURIEnc);
> >>               } catch (UnsupportedEncodingException e) {
> >>                       // TODO Auto-generated catch block
> >> @@ -213,19 +274,32 @@ public class Rule extends NavigationMixi
> >>               }
> >>
> >>       System.out.println("RECIPE IRI : "+IRI.create(recipeURI).toString());
> >> -       OWLOntology ontology =
> >> kReSGetRule.getAllRulesOfARecipe(IRI.create(recipeURI));
> >> +               OWLOntology ontology =
> >> kReSGetRule.getAllRulesOfARecipe(IRI
> >> +                               .create(recipeURI));
> >>
> >>       return Response.ok(ontology).build();
> >>
> >> -
> >>      }
> >> +
> >>     /**
> >> -     * To add a rule to a recipe at the end of the sequence.
> >> -     * curl -v -X POST -F
> >> "recipe=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaParentRecipe"
> >> -F "rule=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaRuleNEW"
> >> -F "kres-syntax=body -> head" -F "description=prova di aggiunta regola"
> >> http://localhost:8080/kres/rule
> >> -     * @param recipe {A string contains the IRI of the recipe where to
> >> add the rule}
> >> -     * @param rule {A string contains the IRI of the rule to be added at
> >> the recipe}
> >> -     * @param kres_syntax {A string contains the body and the head of
> >> the kres rule. If not specified the rule is search in the Ontology
> >> otherwise is added as new.}
> >> -     * @param description {A string contains a description of the rule}
> >> +        * To add a rule to a recipe at the end of the sequence. curl -v
> >> -X POST -F
> >> +        *
> >> "recipe=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaParentRecipe"
> >> +        * -F
> >> "rule=http://kres.iks-project.eu/ontology/meta/rmi.owl%23ProvaRuleNEW"
> >> +        * -F "kres-syntax=body -> head" -F "description=prova di
> >> aggiunta regola"
> >> +        * http://localhost:8080/kres/rule
> >> +        *
> >> +        * @param recipe
> >> +        *            {A string contains the IRI of the recipe where to
> >> add the
> >> +        *            rule}
> >> +        * @param rule
> >> +        *            {A string contains the IRI of the rule to be added
> >> at the
> >> +        *            recipe}
> >> +        * @param kres_syntax
> >> +        *            {A string contains the body and the head of the
> >> kres rule. If
> >> +        *            not specified the rule is search in the Ontology
> >> otherwise is
> >> +        *            added as new.}
> >> +        * @param description
> >> +        *            {A string contains a description of the rule}
> >>       * @return Return: <br/>
> >>       *      200 The rule has been added <br/>
> >>       *      204 The rule has not been added <br/>
> >> @@ -236,7 +310,10 @@ public class Rule extends NavigationMixi
> >>       */
> >>      @POST
> >>      @Consumes(MediaType.MULTIPART_FORM_DATA)
> >> -    public Response addRuleToRecipe(@FormParam(value="recipe") String
> >> recipe,@FormParam(value="rule") String
> >> rule,@FormParam(value="kres-syntax") String
> >> kres_syntax,@FormParam(value="description") String description){
> >> +       public Response addRuleToRecipe(@FormParam(value = "recipe")
> >> String recipe,
> >> +                       @FormParam(value = "rule") String rule,
> >> +                       @FormParam(value = "kres-syntax") String
> >> kres_syntax,
> >> +                       @FormParam(value = "description") String
> >> description) {
> >>
> >>  //        System.err.println("recipe "+recipe);
> >>  //        System.err.println("rule " + rule);
> >> @@ -306,7 +383,8 @@ public class Rule extends NavigationMixi
> >>           if((kres_syntax!=null)&(description!=null)){
> >>              //Get the rule
> >>              KReSAddRule inrule = new KReSAddRule(kresRuleStore);
> >> -            boolean ok =
> >> inrule.addRule(IRI.create(rule),kres_syntax,description);
> >> +                               boolean ok =
> >> inrule.addRule(IRI.create(rule), kres_syntax,
> >> +                                               description);
> >>              if(!ok){
> >>                  System.err.println("PROBLEM TO ADD: "+rule);
> >>                  return Response.status(Status.CONFLICT).build();
> >> @@ -341,7 +419,6 @@ public class Rule extends NavigationMixi
> >>                  return Response.status(Status.CONFLICT).build();
> >>              }
> >>
> >> -
> >>              //Add the recipe with the new rule
> >>              KReSAddRecipe newadd = new KReSAddRecipe(kresRuleStore);
> >>              ok = newadd.addRecipe(IRI.create(recipe), ruleseq, desc);
> >> @@ -361,14 +438,17 @@ public class Rule extends NavigationMixi
> >>      }
> >>
> >>     /**
> >> -     * To delete a rule from a recipe or from the ontology. If the
> >> recipe is not specified the rule is deleted from the ontology.
> >> -     * curl -v -X DELETE -G \
> >> -     * -d
> >> recipe="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRecipe"
> >> \
> >> -     * -d
> >> rule="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentNewRule"
> >> \
> >> +        * To delete a rule from a recipe or from the ontology. If the
> >> recipe is not
> >> +        * specified the rule is deleted from the ontology. curl -v -X
> >> DELETE -G \
> >> +        * -d recipe=
> >> +        *
> >> "http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentRecipe" \ -d
> >> +        * rule
> >> +        *
> >> ="http://kres.iks-project.eu/ontology/meta/rmi.owl#ProvaParentNewRule" \
> >>       * http://localhost:port/kres/rule
> >>      *
> >>       * @Param rule {A string contains an IRI of the rule to be removed}
> >> -     * @param recipe {A string contains an IRI of the recipe where
> >> remove the rule}
> >> +        * @param recipe
> >> +        *            {A string contains an IRI of the recipe where
> >> remove the rule}
> >>       * @return Return: <br/>
> >>       *      200 The rule has been deleted<br/>
> >>       *      204 The rule has not been deleted<br/>
> >> @@ -379,7 +459,8 @@ public class Rule extends NavigationMixi
> >>      @DELETE
> >>      //@Consumes(MediaType.TEXT_PLAIN)
> >>      @Produces(KReSFormat.TEXT_PLAIN)
> >> -    public Response removeRule(@QueryParam(value="rule") String
> >> rule,@QueryParam(value="recipe") String recipe){
> >> +       public Response removeRule(@QueryParam(value = "rule") String
> >> rule,
> >> +                       @QueryParam(value = "recipe") String recipe) {
> >>
> >>          boolean ok;
> >>
> >> @@ -408,7 +489,8 @@ public class Rule extends NavigationMixi
> >>              }
> >>
> >>              KReSRemoveRule remove = new KReSRemoveRule(kresRuleStore);
> >> -            ok =
> >> remove.removeRuleFromRecipe(IRI.create(rule),IRI.create(recipe));
> >> +                               ok =
> >> remove.removeRuleFromRecipe(IRI.create(rule), IRI
> >> +                                               .create(recipe));
> >>              if(ok){
> >>                  kresRuleStore.saveOntology();
> >>                  return Response.status(Status.OK).build();
> >>
> >> Modified:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
> >> (original)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/Classify.java
> >> Wed Dec 29 18:04:19 2010
> >> @@ -5,31 +5,14 @@
> >>
> >>  package eu.iksproject.kres.jersey.reasoners;
> >>
> >> -import com.hp.hpl.jena.rdf.model.Model;
> >> -import com.hp.hpl.jena.rdf.model.ModelFactory;
> >> -import com.hp.hpl.jena.rdf.model.Resource;
> >> -import eu.iksproject.kres.api.format.KReSFormat;
> >> -import eu.iksproject.kres.api.manager.ontology.OntologyScope;
> >> -import eu.iksproject.kres.api.manager.ontology.OntologySpace;
> >> -import eu.iksproject.kres.api.manager.ontology.ScopeRegistry;
> >> -import eu.iksproject.kres.api.manager.ontology.SessionOntologySpace;
> >> -import eu.iksproject.kres.api.rules.KReSRule;
> >> -import eu.iksproject.kres.api.rules.NoSuchRecipeException;
> >> -import eu.iksproject.kres.api.rules.RuleStore;
> >> -import eu.iksproject.kres.api.rules.util.KReSRuleList;
> >> -import eu.iksproject.kres.manager.ONManager;
> >> -import eu.iksproject.kres.reasoners.KReSCreateReasoner;
> >> -import eu.iksproject.kres.reasoners.KReSRunReasoner;
> >> -import eu.iksproject.kres.reasoners.KReSRunRules;
> >> -import eu.iksproject.kres.rules.KReSKB;
> >> -import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >> -import eu.iksproject.kres.rules.parser.KReSRuleParser;
> >>  import java.io.File;
> >>  import java.net.URL;
> >> +import java.util.Hashtable;
> >>  import java.util.Iterator;
> >>  import java.util.LinkedList;
> >>  import java.util.List;
> >>  import java.util.Set;
> >> +
> >>  import javax.servlet.ServletContext;
> >>  import javax.ws.rs.Consumes;
> >>  import javax.ws.rs.FormParam;
> >> @@ -41,6 +24,7 @@ import javax.ws.rs.core.Context;
> >>  import javax.ws.rs.core.MediaType;
> >>  import javax.ws.rs.core.Response;
> >>  import javax.ws.rs.core.Response.Status;
> >> +
> >>  import org.semanticweb.owlapi.apibinding.OWLManager;
> >>  import org.semanticweb.owlapi.model.AddImport;
> >>  import org.semanticweb.owlapi.model.IRI;
> >> @@ -55,7 +39,32 @@ import org.semanticweb.owlapi.model.OWLO
> >>  import org.semanticweb.owlapi.model.OWLOntologyChange;
> >>  import org.semanticweb.owlapi.model.OWLOntologyManager;
> >>  import org.semanticweb.owlapi.reasoner.InconsistentOntologyException;
> >> +import org.slf4j.Logger;
> >> +import org.slf4j.LoggerFactory;
> >>
> >> +import com.hp.hpl.jena.rdf.model.Model;
> >> +import com.hp.hpl.jena.rdf.model.ModelFactory;
> >> +import com.hp.hpl.jena.rdf.model.Resource;
> >> +
> >> +import eu.iksproject.kres.api.format.KReSFormat;
> >> +import eu.iksproject.kres.api.manager.KReSONManager;
> >> +import eu.iksproject.kres.api.manager.ontology.OntologyScope;
> >> +import eu.iksproject.kres.api.manager.ontology.OntologySpace;
> >> +import eu.iksproject.kres.api.manager.ontology.ScopeRegistry;
> >> +import eu.iksproject.kres.api.manager.ontology.SessionOntologySpace;
> >> +import eu.iksproject.kres.api.rules.KReSRule;
> >> +import eu.iksproject.kres.api.rules.NoSuchRecipeException;
> >> +import eu.iksproject.kres.api.rules.RuleStore;
> >> +import eu.iksproject.kres.api.rules.util.KReSRuleList;
> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
> >> +import eu.iksproject.kres.manager.ONManager;
> >> +import eu.iksproject.kres.reasoners.KReSCreateReasoner;
> >> +import eu.iksproject.kres.reasoners.KReSRunReasoner;
> >> +import eu.iksproject.kres.reasoners.KReSRunRules;
> >> +import eu.iksproject.kres.rules.KReSKB;
> >> +import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >> +import eu.iksproject.kres.rules.parser.KReSRuleParser;
> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
> >>
> >>  /**
> >>   *
> >> @@ -68,49 +77,94 @@ public class Classify {
> >>       private OWLOntology inputowl;
> >>       private OWLOntology scopeowl;
> >>
> >> +       protected KReSONManager onm;
> >> +       protected OntologyStoreProvider storeProvider;
> >> +
> >> +       private Logger log = LoggerFactory.getLogger(getClass());
> >> +
> >>      /**
> >>       * To get the KReSRuleStore where are stored the rules and the
> >>       recipes
> >>       *
> >> -     * @param servletContext {To get the context where the REST service
> >> is running.}
> >> +        * @param servletContext
> >> +        *            {To get the context where the REST service is
> >> running.}
> >>       */
> >>      public Classify(@Context ServletContext servletContext){
> >> -       this.kresRuleStore = (RuleStore)
> >> servletContext.getAttribute(RuleStore.class.getName());
> >> +               this.kresRuleStore = (RuleStore) servletContext
> >> +                               .getAttribute(RuleStore.class.getName());
> >> +               this.onm = (KReSONManager) servletContext
> >> +
> >> .getAttribute(KReSONManager.class.getName());
> >> +               this.storeProvider = (OntologyStoreProvider)
> >> servletContext
> >> +
> >> .getAttribute(OntologyStoreProvider.class.getName());
> >> +               // Contingency code for missing components follows.
> >> +               /*
> >> +                * FIXME! The following code is required only for the
> >> tests. This should
> >> +                * be removed and the test should work without this code.
> >> +                */
> >> +               if (storeProvider == null) {
> >> +                       log
> >> +                                       .warn("No OntologyStoreProvider
> >> in servlet context. Instantiating manually...");
> >> +                       storeProvider = new
> >> OntologyStorageProviderImpl();
> >> +               }
> >> +               if (onm == null) {
> >> +                       log
> >> +                                       .warn("No KReSONManager in
> >> servlet context. Instantiating manually...");
> >> +                       onm = new
> >> ONManager(storeProvider.getActiveOntologyStorage(),
> >> +                                       new Hashtable<String, Object>());
> >> +               }
> >>         if (kresRuleStore == null) {
> >> -            System.err.println("WARNING: KReSRuleStore with stored rules
> >> and recipes is missing in ServletContext. A new instance has been
> >> created.");
> >> -            this.kresRuleStore = new KReSRuleStore("");
> >> -            System.err.println("PATH TO OWL FILE LOADED:
> >> "+kresRuleStore.getFilePath());
> >> -//            throw new IllegalStateException(
> >> -//                    "KReSRuleStore with stored rules and recipes is
> >> missing in ServletContext");
> >> +                       log
> >> +                                       .warn("No KReSRuleStore with
> >> stored rules and recipes found in servlet context. Instantiating manually
> >> with default values...");
> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
> >> +                                       new Hashtable<String, Object>(),
> >> "");
> >> +                       log
> >> +                                       .debug("PATH TO OWL FILE LOADED:
> >> "
> >> +                                                       +
> >> kresRuleStore.getFilePath());
> >>          }
> >>      }
> >>
> >>       /**
> >>       * To trasform a sequence of rules to a Jena Model
> >> -     * @param owl {OWLOntology object contains a single recipe}
> >> +        *
> >> +        * @param owl
> >> +        *            {OWLOntology object contains a single recipe}
> >>       * @return {A jena rdf model contains the SWRL rule.}
> >>       */
> >> -    private Model fromRecipeToModel(OWLOntology owl) throws
> >> NoSuchRecipeException{
> >> +       private Model fromRecipeToModel(OWLOntology owl)
> >> +                       throws NoSuchRecipeException {
> >>
> >> -        RuleStore store = new KReSRuleStore(owl);
> >> +               // FIXME: why the heck is this method re-instantiating a
> >> rule store?!?
> >> +               RuleStore store = new KReSRuleStore(onm,
> >> +                               new Hashtable<String, Object>(), owl);
> >>          Model jenamodel = ModelFactory.createDefaultModel();
> >>
> >> -        OWLDataFactory factory =
> >> owl.getOWLOntologyManager().getOWLDataFactory();
> >> -        OWLClass ontocls =
> >> factory.getOWLClass(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"));
> >> +               OWLDataFactory factory = owl.getOWLOntologyManager()
> >> +                               .getOWLDataFactory();
> >> +               OWLClass ontocls = factory
> >> +                               .getOWLClass(IRI
> >> +
> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#Recipe"));
> >>          Set<OWLClassAssertionAxiom> cls =
> >>          owl.getClassAssertionAxioms(ontocls);
> >>          Iterator<OWLClassAssertionAxiom> iter = cls.iterator();
> >>          IRI recipeiri =
> >>          IRI.create(iter.next().getIndividual().toStringID());
> >>
> >> -       OWLIndividual recipeIndividual =
> >> factory.getOWLNamedIndividual(recipeiri);
> >> +               OWLIndividual recipeIndividual = factory
> >> +                               .getOWLNamedIndividual(recipeiri);
> >>
> >> -       OWLObjectProperty objectProperty =
> >> factory.getOWLObjectProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
> >> -       Set<OWLIndividual> rules =
> >> recipeIndividual.getObjectPropertyValues(objectProperty,
> >> store.getOntology());
> >> +               OWLObjectProperty objectProperty = factory
> >> +                               .getOWLObjectProperty(IRI
> >> +
> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasRule"));
> >> +               Set<OWLIndividual> rules =
> >> recipeIndividual.getObjectPropertyValues(
> >> +                               objectProperty, store.getOntology());
> >>          String kReSRules = "";
> >>          for(OWLIndividual rule : rules){
> >> -                       OWLDataProperty hasBodyAndHead =
> >> factory.getOWLDataProperty(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"));
> >> -                       Set<OWLLiteral> kReSRuleLiterals =
> >> rule.getDataPropertyValues(hasBodyAndHead, store.getOntology());
> >> +                       OWLDataProperty hasBodyAndHead = factory
> >> +                                       .getOWLDataProperty(IRI
> >> +
> >> .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#hasBodyAndHead"));
> >> +                       Set<OWLLiteral> kReSRuleLiterals =
> >> rule.getDataPropertyValues(
> >> +                                       hasBodyAndHead,
> >> store.getOntology());
> >>
> >>                       for(OWLLiteral kReSRuleLiteral : kReSRuleLiterals){
> >> -                               kReSRules += kReSRuleLiteral.getLiteral()
> >> + System.getProperty("line.separator");
> >> +                               kReSRules += kReSRuleLiteral.getLiteral()
> >> +                                               +
> >> System.getProperty("line.separator");
> >>                       }
> >>               }
> >>
> >> @@ -128,13 +182,24 @@ public class Classify {
> >>      }
> >>
> >>     /**
> >> -     * To run a classifying reasoner on a RDF input File or IRI on the
> >> base of a Scope (or an ontology) and a recipe. Can be used either HermiT
> >> or an owl-link server reasoner end-point
> >> -     * @param session {A string contains the session IRI used to
> >> classify the input.}
> >> -     * @param scope {A string contains either a specific scope's
> >> ontology or the scope IRI used to classify the input.}
> >> -     * @param recipe {A string contains the recipe IRI from the service
> >> http://localhost:port/kres/recipe/recipeName.}
> >> +        * To run a classifying reasoner on a RDF input File or IRI on
> >> the base of a
> >> +        * Scope (or an ontology) and a recipe. Can be used either HermiT
> >> or an
> >> +        * owl-link server reasoner end-point
> >> +        *
> >> +        * @param session
> >> +        *            {A string contains the session IRI used to classify
> >> the
> >> +        *            input.}
> >> +        * @param scope
> >> +        *            {A string contains either a specific scope's
> >> ontology or the
> >> +        *            scope IRI used to classify the input.}
> >> +        * @param recipe
> >> +        *            {A string contains the recipe IRI from the service
> >> +        *            http://localhost:port/kres/recipe/recipeName.}
> >>       * @Param file {A file in a RDF (eihter RDF/XML or owl) to be
> >>       classified.}
> >> -     * @Param input_graph {A string contains the IRI of RDF (either
> >> RDF/XML or OWL) to be classified.}
> >> -     * @Param owllink_endpoint {A string contains the ressoner server
> >> end-point URL.}
> >> +        * @Param input_graph {A string contains the IRI of RDF (either
> >> RDF/XML or
> >> +        *        OWL) to be classified.}
> >> +        * @Param owllink_endpoint {A string contains the ressoner server
> >> end-point
> >> +        *        URL.}
> >>       * @return Return: <br/>
> >>       *          200 The ontology is retrieved, containing only class
> >>       axioms <br/>
> >>       *          400 To run the session is needed the scope <br/>
> >> @@ -144,8 +209,15 @@ public class Classify {
> >>       */
> >>      @POST
> >>      @Consumes(MediaType.MULTIPART_FORM_DATA)
> >> -
> >> @Produces(value={KReSFormat.RDF_XML,KReSFormat.TURTLE,KReSFormat.OWL_XML})
> >> -    public Response ontologyClassify(@FormParam(value="session") String
> >> session,@FormParam(value="scope") String scope,@FormParam(value="recipe")
> >> String recipe,@FormParam(value="input-graph") String
> >> input_graph,@FormParam(value="file") File
> >> file,@FormParam(value="owllink-endpoint") String owllink_endpoint){
> >> +       @Produces(value = { KReSFormat.RDF_XML, KReSFormat.TURTLE,
> >> +                       KReSFormat.OWL_XML })
> >> +       public Response ontologyClassify(
> >> +                       @FormParam(value = "session") String session,
> >> +                       @FormParam(value = "scope") String scope,
> >> +                       @FormParam(value = "recipe") String recipe,
> >> +                       @FormParam(value = "input-graph") String
> >> input_graph,
> >> +                       @FormParam(value = "file") File file,
> >> +                       @FormParam(value = "owllink-endpoint") String
> >> owllink_endpoint) {
> >>
> >>        try{
> >>
> >> @@ -162,22 +234,28 @@ public class Classify {
> >>
> >>        //Load input file or graph
> >>        if(file!=null)
> >> -        this.inputowl =
> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(file);
> >> +                               this.inputowl =
> >> OWLManager.createOWLOntologyManager()
> >> +
> >> .loadOntologyFromOntologyDocument(file);
> >>        if(input_graph!=null)
> >> -        this.inputowl =
> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(input_graph));
> >> +                               this.inputowl =
> >> OWLManager.createOWLOntologyManager()
> >> +
> >> .loadOntologyFromOntologyDocument(
> >> +
> >> IRI.create(input_graph));
> >>        if(inputowl==null&&(session==null||scope==null))
> >>          return Response.status(Status.NOT_FOUND).build();
> >>        if(inputowl==null){
> >>            if(scope!=null)
> >> -            this.inputowl =
> >> OWLManager.createOWLOntologyManager().createOntology();
> >> +                                       this.inputowl =
> >> OWLManager.createOWLOntologyManager()
> >> +
> >> .createOntology();
> >>            else{
> >> -            this.inputowl =
> >> OWLManager.createOWLOntologyManager().createOntology();
> >> +                                       this.inputowl =
> >> OWLManager.createOWLOntologyManager()
> >> +
> >> .createOntology();
> >>            }
> >>        }
> >>
> >>         //Create list to add ontologies as imported
> >>         OWLOntologyManager mgr = inputowl.getOWLOntologyManager();
> >> -       OWLDataFactory factory =
> >> inputowl.getOWLOntologyManager().getOWLDataFactory();
> >> +                       OWLDataFactory factory =
> >> inputowl.getOWLOntologyManager()
> >> +                                       .getOWLDataFactory();
> >>         List<OWLOntologyChange> additions = new
> >>         LinkedList<OWLOntologyChange>();
> >>
> >>         boolean ok = false;
> >> @@ -187,16 +265,22 @@ public class Classify {
> >>        if((scope!=null)&&(session==null))
> >>        try{
> >>            IRI iri = IRI.create(scope);
> >> -          ScopeRegistry reg = ONManager.get().getScopeRegistry();
> >> +                                       ScopeRegistry reg =
> >> onm.getScopeRegistry();
> >>            OntologyScope ontoscope = reg.getScope(iri);
> >> -          Iterator<OWLOntology> importscope =
> >> ontoscope.getCustomSpace().getOntologies().iterator();
> >> -          Iterator<OntologySpace> importsession =
> >> ontoscope.getSessionSpaces().iterator();
> >> +                                       Iterator<OWLOntology> importscope
> >> = ontoscope
> >> +
> >> .getCustomSpace().getOntologies().iterator();
> >> +                                       Iterator<OntologySpace>
> >> importsession = ontoscope
> >> +
> >> .getSessionSpaces().iterator();
> >>
> >> -          //Add ontology as import form scope, if it is anonymus we try
> >> to add single axioms.
> >> +                                       // Add ontology as import form
> >> scope, if it is anonymus we
> >> +                                       // try to add single axioms.
> >>            while(importscope.hasNext()){
> >>              OWLOntology auxonto = importscope.next();
> >>              if(!auxonto.getOntologyID().isAnonymous()){
> >> -            additions.add(new AddImport(inputowl,
> >> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                                       additions.add(new
> >> AddImport(inputowl, factory
> >> +
> >> .getOWLImportsDeclaration(auxonto
> >> +
> >>               .getOWLOntologyManager()
> >> +
> >>               .getOntologyDocumentIRI(auxonto))));
> >>              }else{
> >>                  mgr.addAxioms(inputowl,auxonto.getAxioms());
> >>              }
> >> @@ -204,11 +288,19 @@ public class Classify {
> >>
> >>           //Add ontology form sessions
> >>           while(importsession.hasNext()){
> >> -             Iterator<OWLOntology> sessionontos =
> >> importsession.next().getOntologies().iterator();
> >> +                                               Iterator<OWLOntology>
> >> sessionontos = importsession
> >> +
> >> .next().getOntologies().iterator();
> >>               while(sessionontos.hasNext()){
> >>                  OWLOntology auxonto = sessionontos.next();
> >>                  if(!auxonto.getOntologyID().isAnonymous()){
> >> -                    additions.add(new AddImport(inputowl,
> >> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                                               additions
> >> +
> >>       .add(new AddImport(
> >> +
> >>                       inputowl,
> >> +
> >>                       factory
> >> +
> >>                                       .getOWLImportsDeclaration(auxonto
> >> +
> >>
> >> .getOWLOntologyManager()
> >> +
> >>
> >> .getOntologyDocumentIRI(
> >> +
> >>
> >> auxonto))));
> >>                  }else{
> >>                      mgr.addAxioms(inputowl,auxonto.getAxioms());
> >>                  }
> >> @@ -226,30 +318,38 @@ public class Classify {
> >>        if((session!=null)&&(scope!=null))
> >>        try{
> >>            IRI iri = IRI.create(scope);
> >> -          ScopeRegistry reg = ONManager.get().getScopeRegistry();
> >> +                                       ScopeRegistry reg =
> >> onm.getScopeRegistry();
> >>            OntologyScope ontoscope = reg.getScope(iri);
> >> -          SessionOntologySpace sos =
> >> ontoscope.getSessionSpace(IRI.create(session));
> >> +                                       SessionOntologySpace sos =
> >> ontoscope.getSessionSpace(IRI
> >> +
> >> .create(session));
> >>
> >> -          Set<OWLOntology> ontos =
> >> sos.getOntologyManager().getOntologies();
> >> +                                       Set<OWLOntology> ontos =
> >> sos.getOntologyManager()
> >> +                                                       .getOntologies();
> >>            Iterator<OWLOntology> iteronto = ontos.iterator();
> >>
> >> -          //Add session ontologies as import, if it is anonymus we try
> >> to add single axioms.
> >> +                                       // Add session ontologies as
> >> import, if it is anonymus we
> >> +                                       // try to add single axioms.
> >>            while(iteronto.hasNext()){
> >>              OWLOntology auxonto = iteronto.next();
> >>              if(!auxonto.getOntologyID().isAnonymous()){
> >> -                additions.add(new AddImport(inputowl,
> >> factory.getOWLImportsDeclaration(auxonto.getOWLOntologyManager().getOntologyDocumentIRI(auxonto))));
> >> +                                                       additions.add(new
> >> AddImport(inputowl, factory
> >> +
> >> .getOWLImportsDeclaration(auxonto
> >> +
> >>               .getOWLOntologyManager()
> >> +
> >>               .getOntologyDocumentIRI(auxonto))));
> >>              }else{
> >>                  mgr.addAxioms(inputowl,auxonto.getAxioms());
> >>              }
> >>            }
> >>
> >>        }catch(Exception e){
> >> -          System.err.println("ERROR: Problem with session: "+session);
> >> +                                       System.err.println("ERROR:
> >> Problem with session: "
> >> +                                                       + session);
> >>            e.printStackTrace();
> >>            Response.status(Status.NOT_FOUND).build();
> >>        }
> >>
> >> -      //After gathered the all ontology as imported now we apply the
> >> changes
> >> +                       // After gathered the all ontology as imported
> >> now we apply the
> >> +                       // changes
> >>        if(additions.size()>0)
> >>          mgr.applyChanges(additions);
> >>
> >> @@ -258,23 +358,35 @@ public class Classify {
> >>
> >>         try{
> >>         if(recipe!=null) {
> >> -            OWLOntology recipeowl =
> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(recipe));
> >> -            //Get Jea RDF model of SWRL rule contained in the recipe
> >> +                                               OWLOntology recipeowl =
> >> OWLManager
> >> +
> >> .createOWLOntologyManager()
> >> +
> >> .loadOntologyFromOntologyDocument(
> >> +
> >>       IRI.create(recipe));
> >> +                                               // Get Jea RDF model of
> >> SWRL rule contained in the
> >> +                                               // recipe
> >>              Model swrlmodel = fromRecipeToModel(recipeowl);
> >>
> >> -            //Create a reasoner to run rules contained in the recipe
> >> -            KReSRunRules rulereasoner = new
> >> KReSRunRules(swrlmodel,inputowl);
> >> -            //Run the rule reasoner to the input RDF with the added
> >> top-ontology
> >> +                                               // Create a reasoner to
> >> run rules contained in the
> >> +                                               // recipe
> >> +                                               KReSRunRules rulereasoner
> >> = new KReSRunRules(swrlmodel,
> >> +
> >> inputowl);
> >> +                                               // Run the rule reasoner
> >> to the input RDF with the added
> >> +                                               // top-ontology
> >>              inputowl = rulereasoner.runRulesReasoner();
> >>         }
> >>
> >>              //Create the reasoner for the classification
> >> -            KReSCreateReasoner newreasoner = new
> >> KReSCreateReasoner(inputowl);
> >> -            //Prepare and start the reasoner to classify ontology's
> >> resources
> >> -            KReSRunReasoner reasoner = new
> >> KReSRunReasoner(newreasoner.getReasoner());
> >> -
> >> -            //Create a new OWLOntology model where to put the inferred
> >> axioms
> >> -            OWLOntology output =
> >> OWLManager.createOWLOntologyManager().createOntology(inputowl.getOntologyID());
> >> +                                       KReSCreateReasoner newreasoner =
> >> new KReSCreateReasoner(
> >> +                                                       inputowl);
> >> +                                       // Prepare and start the reasoner
> >> to classify ontology's
> >> +                                       // resources
> >> +                                       KReSRunReasoner reasoner = new
> >> KReSRunReasoner(newreasoner
> >> +                                                       .getReasoner());
> >> +
> >> +                                       // Create a new OWLOntology model
> >> where to put the inferred
> >> +                                       // axioms
> >> +                                       OWLOntology output =
> >> OWLManager.createOWLOntologyManager()
> >> +
> >> .createOntology(inputowl.getOntologyID());
> >>              //Initial input axioms count
> >>              int startax = output.getAxiomCount();
> >>              //Run the classification
> >> @@ -295,26 +407,40 @@ public class Classify {
> >>             return Response.status(Status.NOT_FOUND).build();
> >>          }
> >>
> >> -      //If there is an owl-link server end-point specified in the form
> >> +                               // If there is an owl-link server
> >> end-point specified in the
> >> +                               // form
> >>        }else{
> >>
> >>        try{
> >>         if(recipe!=null) {
> >> -         OWLOntology recipeowl =
> >> OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(IRI.create(recipe));
> >> -         //Get Jea RDF model of SWRL rule contained in the recipe
> >> +                                               OWLOntology recipeowl =
> >> OWLManager
> >> +
> >> .createOWLOntologyManager()
> >> +
> >> .loadOntologyFromOntologyDocument(
> >> +
> >>       IRI.create(recipe));
> >> +                                               // Get Jea RDF model of
> >> SWRL rule contained in the
> >> +                                               // recipe
> >>           Model swrlmodel = fromRecipeToModel(recipeowl);
> >> -         //Create a reasoner to run rules contained in the recipe by
> >> using the server and-point
> >> -         KReSRunRules rulereasoner = new
> >> KReSRunRules(swrlmodel,inputowl,new URL(owllink_endpoint));
> >> -         //Run the rule reasoner to the input RDF with the added
> >> top-ontology
> >> +                                               // Create a reasoner to
> >> run rules contained in the
> >> +                                               // recipe by using the
> >> server and-point
> >> +                                               KReSRunRules rulereasoner
> >> = new KReSRunRules(swrlmodel,
> >> +                                                               inputowl,
> >> new URL(owllink_endpoint));
> >> +                                               // Run the rule reasoner
> >> to the input RDF with the added
> >> +                                               // top-ontology
> >>           inputowl = rulereasoner.runRulesReasoner();
> >>         }
> >> -         //Create the reasoner for the consistency check by using the
> >> server and-point
> >> -         KReSCreateReasoner newreasoner = new
> >> KReSCreateReasoner(inputowl, new URL(owllink_endpoint));
> >> -         //Prepare and start the reasoner to classify ontology's
> >> resources
> >> -         KReSRunReasoner reasoner = new
> >> KReSRunReasoner(newreasoner.getReasoner());
> >> -
> >> -         //Create a new OWLOntology model where to put the inferred
> >> axioms
> >> -         OWLOntology output =
> >> OWLManager.createOWLOntologyManager().createOntology(inputowl.getOntologyID());
> >> +                                       // Create the reasoner for the
> >> consistency check by using
> >> +                                       // the server and-point
> >> +                                       KReSCreateReasoner newreasoner =
> >> new KReSCreateReasoner(
> >> +                                                       inputowl, new
> >> URL(owllink_endpoint));
> >> +                                       // Prepare and start the reasoner
> >> to classify ontology's
> >> +                                       // resources
> >> +                                       KReSRunReasoner reasoner = new
> >> KReSRunReasoner(newreasoner
> >> +                                                       .getReasoner());
> >> +
> >> +                                       // Create a new OWLOntology model
> >> where to put the inferred
> >> +                                       // axioms
> >> +                                       OWLOntology output =
> >> OWLManager.createOWLOntologyManager()
> >> +
> >> .createOntology(inputowl.getOntologyID());
> >>           //Initial input axioms count
> >>           int startax = output.getAxiomCount();
> >>           //Run the classification
> >>
> >> Modified:
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java?rev=1053689&r1=1053688&r2=1053689&view=diff
> >> ==============================================================================
> >> ---
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
> >> (original)
> >> +++
> >> incubator/stanbol/trunk/kres/eu.iksproject.kres.jersey/src/main/java/eu/iksproject/kres/jersey/reasoners/ConsistencyCheck.java
> >> Wed Dec 29 18:04:19 2010
> >> @@ -2,6 +2,7 @@ package eu.iksproject.kres.jersey.reason
> >>
> >>  import java.io.File;
> >>  import java.net.URL;
> >> +import java.util.Hashtable;
> >>  import java.util.Iterator;
> >>  import java.util.LinkedList;
> >>  import java.util.List;
> >> @@ -14,7 +15,6 @@ import javax.ws.rs.GET;
> >>  import javax.ws.rs.POST;
> >>  import javax.ws.rs.Path;
> >>  import javax.ws.rs.PathParam;
> >> -import javax.ws.rs.Produces;
> >>  import javax.ws.rs.WebApplicationException;
> >>  import javax.ws.rs.core.Context;
> >>  import javax.ws.rs.core.MediaType;
> >> @@ -44,6 +44,7 @@ import com.hp.hpl.jena.rdf.model.Model;
> >>  import com.hp.hpl.jena.rdf.model.ModelFactory;
> >>  import com.hp.hpl.jena.rdf.model.Resource;
> >>
> >> +import eu.iksproject.kres.api.manager.KReSONManager;
> >>  import eu.iksproject.kres.api.manager.OWLDuplicateSafeLoader;
> >>  import eu.iksproject.kres.api.manager.ontology.OntologyScope;
> >>  import eu.iksproject.kres.api.manager.ontology.OntologySpace;
> >> @@ -53,6 +54,7 @@ import eu.iksproject.kres.api.rules.KReS
> >>  import eu.iksproject.kres.api.rules.NoSuchRecipeException;
> >>  import eu.iksproject.kres.api.rules.RuleStore;
> >>  import eu.iksproject.kres.api.rules.util.KReSRuleList;
> >> +import eu.iksproject.kres.api.storage.OntologyStoreProvider;
> >>  import eu.iksproject.kres.manager.ONManager;
> >>  import eu.iksproject.kres.reasoners.KReSCreateReasoner;
> >>  import eu.iksproject.kres.reasoners.KReSRunReasoner;
> >> @@ -60,6 +62,7 @@ import eu.iksproject.kres.reasoners.KReS
> >>  import eu.iksproject.kres.rules.KReSKB;
> >>  import eu.iksproject.kres.rules.manager.KReSRuleStore;
> >>  import eu.iksproject.kres.rules.parser.KReSRuleParser;
> >> +import eu.iksproject.kres.storage.provider.OntologyStorageProviderImpl;
> >>
> >>  /**
> >>   * This class implements the REST interface for the /check-consistency
> >>   service
> >> @@ -75,7 +78,10 @@ public class ConsistencyCheck {
> >>       private OWLOntology scopeowl;
> >>
> >>       private final OWLDuplicateSafeLoader loader = new OWLDuplicateSafeLoader();
> >> -       private final Logger log = LoggerFactory.getLogger(getClass());
> >> +       protected KReSONManager onm;
> >> +       protected OntologyStoreProvider storeProvider;
> >> +
> >> +       private Logger log = LoggerFactory.getLogger(getClass());
> >>
> >>       /**
> >>        * The constructor.
> >> @@ -85,24 +91,40 @@ public class ConsistencyCheck {
> >>        */
> >>       public ConsistencyCheck(@Context ServletContext servletContext) {
> >>
> >> -               /**
> >> -                * Retrieve the rule store
> >> -                */
> >> +               // Retrieve the rule store
> >>               this.kresRuleStore = (RuleStore) servletContext
> >>                               .getAttribute(RuleStore.class.getName());
> >> -               /**
> >> +               // Retrieve the ontology network manager
> >> +               this.onm = (KReSONManager) servletContext
> >> +
> >> .getAttribute(KReSONManager.class.getName());
> >> +               this.storeProvider = (OntologyStoreProvider)
> >> servletContext
> >> +
> >> .getAttribute(OntologyStoreProvider.class.getName());
> >> +               // Contingency code for missing components follows.
> >> +               /*
> >>                * FIXME! The following code is required only for the tests. This should
> >>                * be removed and the test should work without this code.
> >>                */
> >> +               if (storeProvider == null) {
> >> +                       log
> >> +                                       .warn("No OntologyStoreProvider
> >> in servlet context. Instantiating manually...");
> >> +                       storeProvider = new
> >> OntologyStorageProviderImpl();
> >> +               }
> >> +               if (onm == null) {
> >> +                       log
> >> +                                       .warn("No KReSONManager in
> >> servlet context. Instantiating manually...");
> >> +                       onm = new
> >> ONManager(storeProvider.getActiveOntologyStorage(),
> >> +                                       new Hashtable<String, Object>());
> >> +               }
> >>               if (kresRuleStore == null) {
> >>                       log
> >> -                                       .warn(
> >> -                                                       "KReSRuleStore
> >> with stored rules and recipes is missing in ServletContext. A new
> >> instance has been created.",
> >> -                                                       this);
> >> -                       this.kresRuleStore = new KReSRuleStore("");
> >> -                       log.info("Configuration file loaded from: "
> >> +                                       .warn("No KReSRuleStore with
> >> stored rules and recipes found in servlet context. Instantiating manually
> >> with default values...");
> >> +                       this.kresRuleStore = new KReSRuleStore(onm,
> >> +                                       new Hashtable<String, Object>(),
> >> "");
> >> +                       log
> >> +                                       .debug("PATH TO OWL FILE LOADED:
> >> "
> >>                                       + kresRuleStore.getFilePath());
> >>               }
> >> +
> >>       }
> >>
> >>       /**
> >> @@ -115,7 +137,9 @@ public class ConsistencyCheck {
> >>       private Model fromRecipeToModel(OWLOntology owl)
> >>                       throws NoSuchRecipeException, OWLOntologyCreationException {
> >>
> >> -               RuleStore store = new KReSRuleStore(owl);
> >> +               // FIXME: why the heck is this method re-instantiating a
> >> rule store?!?
> >> +               RuleStore store = new KReSRuleStore(onm,
> >> +                               new Hashtable<String, Object>(), owl);
> >>               Model jenamodel = ModelFactory.createDefaultModel();
> >>
> >>               OWLDataFactory factory = owl.getOWLOntologyManager()
> >> @@ -199,7 +223,10 @@ public class ConsistencyCheck {
> >>                               log.debug("Some ontology import failed. Cannot continue.", uu);
> >>                               return Response.status(Status.PRECONDITION_FAILED).build();
> >>                       } catch (Exception ee) {
> >> -                               log.error("Cannot fetch the ontology.
> >> Some error occurred. Cannot continue.", ee);
> >> +                               log
> >> +                                               .error(
> >> +                                                               "Cannot
> >> fetch the ontology. Some error occurred. Cannot continue.",
> >> +                                                               ee);
> >>                               return Response.status(Status.NOT_FOUND).build();
> >>                       }
> >>                       KReSCreateReasoner newreasoner = new KReSCreateReasoner(owl);
> >> @@ -312,7 +339,7 @@ public class ConsistencyCheck {
> >>                       if ((scope != null) && (session == null))
> >>                               try {
> >>                                       IRI iri = IRI.create(scope);
> >> -                                       ScopeRegistry reg =
> >> ONManager.get().getScopeRegistry();
> >> +                                       ScopeRegistry reg =
> >> onm.getScopeRegistry();
> >>                                       OntologyScope ontoscope = reg.getScope(iri);
> >>                                       Iterator<OWLOntology> importscope = ontoscope
> >>                                                       .getCustomSpace().getOntologies().iterator();
> >> @@ -365,7 +392,7 @@ public class ConsistencyCheck {
> >>                       if ((session != null) && (scope != null))
> >>                               try {
> >>                                       IRI iri = IRI.create(scope);
> >> -                                       ScopeRegistry reg =
> >> ONManager.get().getScopeRegistry();
> >> +                                       ScopeRegistry reg =
> >> onm.getScopeRegistry();
> >>                                       OntologyScope ontoscope = reg.getScope(iri);
> >>                                       SessionOntologySpace sos = ontoscope.getSessionSpace(IRI
> >>                                                       .create(session));
> >>
> >>
> >>
> >
> 
> 
> 
> -- 
> Enrico Daga
> Technology Expert
> --
> Ufficio Sistemi Informativi  (DCSPI-USI)
> National Research Council (CNR)
> P.le Aldo Moro 7 - Rome, Italy
> Tel +39 4993 3321
> --
> Semantic Technology Laboratory (STLab)
> Institute for Cognitive Science and Technology (ISTC-CNR)
> Via Nomentana 56, Rome - Italy
> --
> http://stlab.istc.cnr.it/stlab/User:EnricoDaga
> http://www.enridaga.net
> skype: enri-pan
>