You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by al...@apache.org on 2012/10/05 17:35:30 UTC

svn commit: r1394594 [8/9] - in /stanbol/trunk: commons/authentication.basic/ commons/security/ contrib/reengineer/base/ contrib/reengineer/db/ contrib/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/ contrib/reengineer/db/src/test/java/or...

Added: stanbol/trunk/ontologymanager/sources/clerezza/src/test/java/org/apache/stanbol/ontologymanager/sources/clerezza/TestClerezzaInputSources.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/clerezza/src/test/java/org/apache/stanbol/ontologymanager/sources/clerezza/TestClerezzaInputSources.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/clerezza/src/test/java/org/apache/stanbol/ontologymanager/sources/clerezza/TestClerezzaInputSources.java (added)
+++ stanbol/trunk/ontologymanager/sources/clerezza/src/test/java/org/apache/stanbol/ontologymanager/sources/clerezza/TestClerezzaInputSources.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.clerezza;
+
+import static org.apache.stanbol.ontologymanager.sources.clerezza.MockOsgiContext.parser;
+import static org.apache.stanbol.ontologymanager.sources.clerezza.MockOsgiContext.reset;
+import static org.apache.stanbol.ontologymanager.sources.clerezza.MockOsgiContext.tcManager;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestClerezzaInputSources {
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    @BeforeClass
+    public static void loadGraphs() throws Exception {
+        reset();
+    }
+
+    private OntologyInputSource<TripleCollection> gis;
+
+    @Before
+    public void bind() throws Exception {
+
+    }
+
+    @After
+    public void cleanup() {
+        reset();
+    }
+
+    // TODO move this test where we have access to the Clerezza implementation.
+    //
+    // @Test
+    // public void testGraphContentSource() throws Exception {
+    // // Make sure the tc manager has been reset
+    // assertEquals(1, tcManager.listTripleCollections().size());
+    //
+    // OntologyProvider<TcProvider> provider = new ClerezzaOntologyProvider(tcManager,
+    // new OfflineConfigurationImpl(new Hashtable<String,Object>()), parser);
+    // int tcs = tcManager.listTripleCollections().size();
+    // InputStream content = TestClerezzaInputSources.class
+    // .getResourceAsStream("/ontologies/droppedcharacters.owl");
+    // OntologyInputSource<?> src = new GraphContentInputSource(content, SupportedFormat.RDF_XML,
+    // ontologyProvider.getStore(), parser);
+    //
+    // log.info("After input source creation, TcManager has {} graphs. ", tcManager.listTripleCollections()
+    // .size());
+    // for (UriRef name : tcManager.listTripleCollections())
+    // log.info("-- {} (a {})", name, tcManager.getTriples(name).getClass().getSimpleName());
+    // assertEquals(tcs + 1, tcManager.listTripleCollections().size());
+    // Space spc = new CoreSpaceImpl(TestClerezzaInputSources.class.getSimpleName(),
+    // IRI.create("http://stanbol.apache.org/ontologies/"), provider);
+    // spc.addOntology(src);
+    // log.info("After addition to space, TcManager has {} graphs. ", tcManager.listTripleCollections()
+    // .size());
+    //
+    // for (UriRef name : tcManager.listTripleCollections())
+    // log.info("-- {} (a {})", name, tcManager.getTriples(name).getClass().getSimpleName());
+    // // Adding the ontology from the same storage should not create new graphs
+    // assertEquals(tcs + 1, tcManager.listTripleCollections().size());
+    //
+    // }
+
+    @Test
+    public void testGraphSource() throws Exception {
+        UriRef uri = new UriRef(Locations.CHAR_ACTIVE.toString());
+        InputStream inputStream = TestClerezzaInputSources.class
+                .getResourceAsStream("/ontologies/characters_all.owl");
+        parser.parse(tcManager.createMGraph(uri), inputStream, SupportedFormat.RDF_XML, uri);
+        uri = new UriRef(Locations.CHAR_MAIN.toString());
+        inputStream = TestClerezzaInputSources.class.getResourceAsStream("/ontologies/maincharacters.owl");
+        parser.parse(tcManager.createMGraph(uri), inputStream, SupportedFormat.RDF_XML, uri);
+        uri = new UriRef(Locations.CHAR_MINOR.toString());
+        inputStream = TestClerezzaInputSources.class.getResourceAsStream("/ontologies/minorcharacters.owl");
+        parser.parse(tcManager.createMGraph(uri), inputStream, SupportedFormat.RDF_XML, uri);
+
+        gis = new GraphSource(new UriRef(Locations.CHAR_ACTIVE.toString()));
+        assertNotNull(gis);
+        assertNotNull(gis.getRootOntology());
+        // Set<TripleCollection> imported = gis.getImports(false);
+        // // Number of stored graphs minus the importing one minus the reserved graph = imported graphs
+        // assertEquals(tcManager.listTripleCollections().size() - 2, imported.size());
+        // for (TripleCollection g : imported)
+        // assertNotNull(g);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/characters_all.owl
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/characters_all.owl?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/characters_all.owl (added)
+++ stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/characters_all.owl Fri Oct  5 15:35:22 2012
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE rdf:RDF [
+    <!ENTITY foaf "http://xmlns.com/foaf/0.1/" >
+    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+]>
+
+
+<rdf:RDF xmlns="http://stanbol.apache.org/ontologies/pcomics/characters_all.owl#"
+     xml:base="http://stanbol.apache.org/ontologies/pcomics/characters_all.owl"
+     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+     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#">
+    <owl:Ontology rdf:about="http://stanbol.apache.org/ontologies/pcomics/characters_all.owl">
+        <owl:versionInfo xml:lang="en">Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+        </owl:versionInfo>
+            <owl:imports rdf:resource="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl"/>
+            <owl:imports rdf:resource="http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl"/>
+    </owl:Ontology>  
+
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.2.2.1789) http://owlapi.sourceforge.net -->
+

Added: stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/maincharacters.owl
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/maincharacters.owl?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/maincharacters.owl (added)
+++ stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/maincharacters.owl Fri Oct  5 15:35:22 2012
@@ -0,0 +1,102 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE rdf:RDF [
+    <!ENTITY foaf "http://xmlns.com/foaf/0.1/" >
+    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+]>
+
+
+<rdf:RDF xmlns="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#"
+     xml:base="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl"
+     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+     xmlns:foaf="http://xmlns.com/foaf/0.1/"
+     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#">
+    <owl:Ontology rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl">
+        <rdfs:comment>Should import: http://xmlns.com/foaf/0.1/</rdfs:comment>
+        <owl:versionInfo xml:lang="en">Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+        </owl:versionInfo>
+        <owl:imports rdf:resource="http://xmlns.com/foaf/0.1/"/>
+    </owl:Ontology>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Annotation properties
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Datatypes
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Individuals
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Linus -->
+
+    <foaf:Person rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Linus">
+        <rdf:type rdf:resource="&owl;NamedIndividual"/>
+        <rdfs:label xml:lang="en">Linus</rdfs:label>
+    </foaf:Person>
+    
+
+
+    <!-- http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Lucy -->
+
+    <foaf:Perzon rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Lucy">
+        <rdf:type rdf:resource="&owl;NamedIndividual"/>
+        <rdfs:label xml:lang="en">Lucy</rdfs:label>
+        <rdfs:comment xml:lang="en">The typing of this individual as foaf:Perzon is wilful, DO NOT REMOVE.</rdfs:comment>
+    </foaf:Perzon>
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.2.2.1789) http://owlapi.sourceforge.net -->
+

Added: stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/minorcharacters.owl
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/minorcharacters.owl?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/minorcharacters.owl (added)
+++ stanbol/trunk/ontologymanager/sources/clerezza/src/test/resources/ontologies/minorcharacters.owl Fri Oct  5 15:35:22 2012
@@ -0,0 +1,98 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE rdf:RDF [
+    <!ENTITY foaf "http://xmlns.com/foaf/0.1/" >
+    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+]>
+
+
+<rdf:RDF xmlns="http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl#"
+     xml:base="http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl"
+     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+     xmlns:foaf="http://xmlns.com/foaf/0.1/"
+     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#">
+    <owl:Ontology rdf:about="http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl">
+        <rdfs:comment>Should import: http://xmlns.com/foaf/0.1/</rdfs:comment>
+        <owl:versionInfo xml:lang="en">Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+        </owl:versionInfo>
+        <owl:imports rdf:resource="http://xmlns.com/foaf/0.1/"/>
+    </owl:Ontology>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Annotation properties
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Datatypes
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Individuals
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    <!-- http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl#Truffles -->
+
+    <foaf:Person rdf:about="http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl#Truffles">
+        <rdf:type rdf:resource="&owl;NamedIndividual"/>
+        <rdfs:label xml:lang="en">Truffles</rdfs:label>
+    </foaf:Person>    
+
+
+    <!-- http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl#Thibault -->
+
+    <foaf:Person rdf:about="http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl#Thibault">
+        <rdf:type rdf:resource="&owl;NamedIndividual"/>
+        <rdfs:label xml:lang="en">Thibault</rdfs:label>
+    </foaf:Person>
+
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.2.2.1789) http://owlapi.sourceforge.net -->
+

Propchange: stanbol/trunk/ontologymanager/sources/owlapi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Oct  5 15:35:22 2012
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Added: stanbol/trunk/ontologymanager/sources/owlapi/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/pom.xml?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/pom.xml (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/pom.xml Fri Oct  5 15:35:22 2012
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0 
+    
+    Unless required by applicable law or agreed to in writing, software 
+    distributed under the License is distributed on an "AS IS" BASIS, 
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
+    implied. See the License for the specific language governing 
+    permissions and limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>stanbol-parent</artifactId>
+    <version>2-SNAPSHOT</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.ontologymanager.sources.owlapi</artifactId>
+  <version>0.10.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Ontology Manager : Input Sources (OWL API-based)</name>
+  <description>
+    Ontology Manager API extensions for submitting ontologies to the manager. 
+    These implementations are based on the OWL API, therefore operate in-memory 
+    until the ontology is about to be stored.
+  </description>
+
+  <inceptionYear>2012</inceptionYear>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-Activator/>
+            <Bundle-ClassPath>.</Bundle-ClassPath>
+            <Export-Package>
+              org.apache.stanbol.ontologymanager.ontonet.io.*, <!-- DEPRECATED -->
+              org.apache.stanbol.ontologymanager.sources.owlapi.*;version=${project.version}
+            </Export-Package>
+            <Import-Package>
+              org.semanticweb.owlapi.*,
+              org.slf4j.*,
+              *
+            </Import-Package>
+            <_nouses>true</_nouses>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+
+    <!-- Stanbol deps -->
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.ontologymanager.servicesapi</artifactId>
+      <version>0.10.0-SNAPSHOT</version>
+    </dependency>
+
+  </dependencies>
+
+</project>

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/license/THIRD-PARTY.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/license/THIRD-PARTY.properties?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/license/THIRD-PARTY.properties (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/license/THIRD-PARTY.properties Fri Oct  5 15:35:22 2012
@@ -0,0 +1,26 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Apache 2
+# - Apache License
+# - BSD
+# - BSD-style license
+# - CDDL 1.1
+# - Common Development and Distribution License (CDDL) v1.0
+# - Common Public License Version 1.0
+# - GPL2 w/ CPE
+# - ICU License
+# - MIT License
+# - The Apache Software License, Version 2.0
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Wed Feb 15 19:05:02 CET 2012
+asm--asm--3.1=BSD License
+javax.servlet--servlet-api--2.4=Common Development And Distribution License (CDDL), Version 1.0
+org.codehaus.jettison--jettison--1.3=The Apache Software License, Version 2.0
+org.osgi--org.osgi.compendium--4.1.0=The Apache Software License, Version 2.0
+org.osgi--org.osgi.core--4.1.0=The Apache Software License, Version 2.0
+owlapi--owlapi--3.2.3=The Apache Software License, Version 2.0
+xerces--xercesImpl--2.7.1=The Apache Software License, Version 2.0

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+@Deprecated
+public abstract class AbstractOWLOntologyInputSource extends
+        org.apache.stanbol.ontologymanager.sources.owlapi.AbstractOWLOntologyInputSource {
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+@Deprecated
+public class BlankOntologySource extends
+        org.apache.stanbol.ontologymanager.sources.owlapi.BlankOntologySource {
+
+    public BlankOntologySource() {
+        super();
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+import java.io.InputStream;
+
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+@Deprecated
+public class OntologyContentInputSource extends
+        org.apache.stanbol.ontologymanager.sources.owlapi.OntologyContentInputSource {
+
+    public OntologyContentInputSource(InputStream content) throws OWLOntologyCreationException {
+        super(content);
+    }
+
+    public OntologyContentInputSource(InputStream content, OWLOntologyManager manager) throws OWLOntologyCreationException {
+        super(content, manager);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace;
+
+@Deprecated
+public class OntologySpaceSource extends
+        org.apache.stanbol.ontologymanager.sources.owlapi.OntologySpaceSource {
+
+    public OntologySpaceSource(OntologySpace space) {
+        super(space);
+    }
+
+    public OntologySpaceSource(OntologySpace space, Set<OntologyInputSource<?>> subtrees) {
+        super(space, subtrees);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+import java.io.File;
+
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+@Deprecated
+public class ParentPathInputSource extends
+        org.apache.stanbol.ontologymanager.sources.owlapi.ParentPathInputSource {
+
+    public ParentPathInputSource(File rootFile) throws OWLOntologyCreationException {
+        super(rootFile);
+    }
+
+    public ParentPathInputSource(File rootFile, OWLOntologyManager mgr) throws OWLOntologyCreationException {
+        super(rootFile, mgr);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+@Deprecated
+public class RootOntologyIRISource extends
+        org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologyIRISource {
+
+    public RootOntologyIRISource(IRI rootPhysicalIri) throws OWLOntologyCreationException {
+        super(rootPhysicalIri);
+    }
+
+    public RootOntologyIRISource(IRI rootPhysicalIri, OWLOntologyManager manager) throws OWLOntologyCreationException {
+        super(rootPhysicalIri, manager);
+    }
+
+    public RootOntologyIRISource(IRI rootPhysicalIri, OWLOntologyManager manager, boolean ignoreIriMappers) throws OWLOntologyCreationException {
+        super(rootPhysicalIri, manager, ignoreIriMappers);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+import org.semanticweb.owlapi.model.OWLOntology;
+
+@Deprecated
+public class RootOntologySource extends org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologySource {
+
+    public RootOntologySource(OWLOntology rootOntology) {
+        super(rootOntology);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyImportUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyImportUtils.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyImportUtils.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyImportUtils.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.servicesapi.util;
+
+import java.io.PrintStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace;
+import org.apache.stanbol.ontologymanager.sources.owlapi.OntologySpaceSource;
+import org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologySource;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
+import org.semanticweb.owlapi.io.StringDocumentTarget;
+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.OWLImportsDeclaration;
+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.semanticweb.owlapi.model.UnknownOWLOntologyException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A set of static utility methods for managing ontologies.
+ * 
+ * @author alexdma
+ * 
+ */
+public class OntologyImportUtils {
+
+    private static final Logger logger = LoggerFactory.getLogger(OntologyImportUtils.class);
+
+    public static OWLOntology buildImportTree(OntologyInputSource<OWLOntology> rootSrc,
+                                              Set<OWLOntology> subtrees) {
+        return buildImportTree(rootSrc.getRootOntology(), subtrees, OWLManager.createOWLOntologyManager());
+    }
+
+    /**
+     * 
+     * @param rootSrc
+     * @param subtrees
+     * @param mgr
+     * @return
+     */
+    public static OWLOntology buildImportTree(OntologyInputSource<OWLOntology> rootSrc,
+                                              Set<OWLOntology> subtrees,
+                                              OWLOntologyManager mgr) {
+
+        if (rootSrc instanceof OntologySpaceSource) {
+            OntologySpace spc = ((OntologySpaceSource) rootSrc).asOntologySpace();
+            for (OWLOntology o : subtrees)
+                try {
+                    spc.addOntology(new RootOntologySource(o));
+                } catch (UnmodifiableOntologyCollectorException e) {
+                    logger.error("Cannot add ontology {} to unmodifiable space {}", o, spc);
+                    continue;
+                }
+        }
+
+        return buildImportTree(rootSrc.getRootOntology(), subtrees, mgr);
+
+    }
+
+    /**
+     * Non-recursively adds import statements to the root ontology so that it is directly linked to all the
+     * ontologies in the subtrees set.
+     * 
+     * @param root
+     *            the ontology to which import subtrees should be appended. If null, a runtime exception will
+     *            be thrown.
+     * @param subtrees
+     *            the set of target ontologies for import statements. These can in turn be importing other
+     *            ontologies, hence the &quot;subtree&quot; notation. A single statement will be added for
+     *            each member of this set.
+     * @return the same input ontology as defined in <code>root</code>, but with the added import statements.
+     */
+    public static OWLOntology buildImportTree(OWLOntology root, Set<OWLOntology> subtrees) {
+        return buildImportTree(root, subtrees, OWLManager.createOWLOntologyManager());
+    }
+
+    /**
+     * Non-recursively adds import statements to the root ontology so that it is directly linked to all the
+     * ontologies in the subtrees set.
+     * 
+     * @param parent
+     *            the ontology to which import subtrees should be appended. If null, a runtime exception will
+     *            be thrown.
+     * @param subtrees
+     *            the set of target ontologies for import statements. These can in turn be importing other
+     *            ontologies, hence the &quot;subtree&quot; notation. A single statement will be added for
+     *            each member of this set.
+     * @param mgr
+     *            the OWL ontology manager to use for constructing the import tree. If null, an internal one
+     *            will be used instead, otherwise an existing ontology manager can be used e.g. for extracting
+     *            import statements from its IRI mappers or known ontologies. Note that the supplied manager
+     *            will <i>never</i> try to load any ontologies, even when they are unknown.
+     * @return the same input ontology as defined in <code>root</code>, but with the added import statements.
+     */
+    public static OWLOntology buildImportTree(OWLOntology parent,
+                                              Set<OWLOntology> subtrees,
+                                              OWLOntologyManager mgr) {
+
+        if (parent == null) throw new NullPointerException(
+                "Cannot append import trees to a nonexistent ontology.");
+
+        // If no manager was supplied, use a temporary one.
+        if (mgr == null) mgr = OWLManager.createOWLOntologyManager();
+        OWLDataFactory owlFactory = mgr.getOWLDataFactory();
+        List<OWLOntologyChange> changes = new LinkedList<OWLOntologyChange>();
+
+        for (OWLOntology o : subtrees) {
+
+            IRI importIri = null;
+            try {
+                /*
+                 * First query the manager, as it could know the physical location of anonymous ontologies, if
+                 * previously loaded or IRI-mapped.
+                 */
+                importIri = mgr.getOntologyDocumentIRI(o);
+            } catch (UnknownOWLOntologyException ex) {
+                /*
+                 * Otherwise, ask the ontology itself (the location of an anonymous ontology may have been
+                 * known at creation/loading time, even if another manager built it.)
+                 */
+                importIri = o.getOntologyID().getDefaultDocumentIRI();
+            } catch (Exception ex) {
+                logger.error(
+                    "Exception caught during tree building. Skipping import of ontology " + o.getOntologyID(),
+                    ex);
+            } finally {
+                /*
+                 * It is still possible that an imported ontology is anonymous but has no physical document
+                 * IRI (for example, because it was only generated in-memory but not stored). In this case it
+                 * is necessary (and generally safe) to copy all its axioms and import statements to the
+                 * parent ontology, or else it is lost.
+                 */
+                if (o.isAnonymous() && importIri == null) {
+                    logger.warn("Anonymous import target "
+                                + o.getOntologyID()
+                                + " not mapped to physical IRI. Will add extracted axioms to parent ontology.");
+                    for (OWLImportsDeclaration im : o.getImportsDeclarations())
+                        changes.add(new AddImport(parent, im));
+                    for (OWLAxiom im : o.getAxioms())
+                        changes.add(new AddAxiom(parent, im));
+                } else if (importIri != null) {
+                    // An anonymous ontology can still be imported if it has a
+                    // valid document IRI.
+                    changes.add(new AddImport(parent, owlFactory.getOWLImportsDeclaration(importIri)));
+                }
+            }
+
+        } // End subtrees cycle.
+
+        // All possible error causes should have been dealt with by now, but we
+        // apply the changes one by one, just in case.
+        for (OWLOntologyChange im : changes)
+            try {
+                mgr.applyChange(im);
+            } catch (Exception ex) {
+                logger.error("KReS :: Exception caught during tree building. Skipping import", ex);
+                continue;
+            }
+        // mgr.applyChanges(changes);
+
+        return parent;
+    }
+
+    public static OWLOntology buildImportTree(Set<OWLOntology> subtrees) throws OWLOntologyCreationException {
+        return buildImportTree(subtrees, OWLManager.createOWLOntologyManager());
+    }
+
+    public static OWLOntology buildImportTree(Set<OWLOntology> subtrees, OWLOntologyManager mgr) throws OWLOntologyCreationException {
+        return buildImportTree(new RootOntologySource(mgr.createOntology()), subtrees, mgr);
+    }
+
+    @Deprecated
+    public static void printOntology(OWLOntology o, PrintStream printer) {
+
+        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
+        StringDocumentTarget tgt = new StringDocumentTarget();
+        try {
+            mgr.saveOntology(o, new RDFXMLOntologyFormat(), tgt);
+        } catch (OWLOntologyStorageException e) {
+            e.printStackTrace(printer);
+        }
+        printer.println(tgt.toString());
+
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/AbstractOWLOntologyInputSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/AbstractOWLOntologyInputSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/AbstractOWLOntologyInputSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/AbstractOWLOntologyInputSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import org.apache.stanbol.ontologymanager.servicesapi.io.AbstractGenericInputSource;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+/**
+ * Abstract OWL API implementation of {@link OntologyInputSource} with the basic methods for obtaining root
+ * ontologies and their physical IRIs where applicable.<br/>
+ * </br> Implementations should either invoke abstract methods {@link #bindPhysicalOrigin(IRI)} and
+ * {@link #bindRootOntology(OWLOntology)} in their constructors, or override them.
+ * 
+ */
+public abstract class AbstractOWLOntologyInputSource extends AbstractGenericInputSource<OWLOntology> {
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/BlankOntologySource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/BlankOntologySource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/BlankOntologySource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/BlankOntologySource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+/**
+ * A utility input source that contains an unnamed, empty ontology. An example usage of this class is to avoid
+ * a {@link NullPointerException} to be thrown when an {@link OntologyInputSource} is to be passed to a
+ * method, but we are not actually interested in the ontology to pass.
+ * 
+ * @author alexdma
+ * 
+ */
+public class BlankOntologySource extends AbstractOWLOntologyInputSource {
+
+    /**
+     * Creates a new input source with an unnamed, empty ontology.
+     */
+    public BlankOntologySource() {
+        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
+        try {
+            bindRootOntology(manager.createOntology());
+        } catch (OWLOntologyCreationException e) {
+            bindRootOntology(null);
+        }
+        bindPhysicalOrigin(null);
+    }
+
+    @Override
+    public String toString() {
+        return "";
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologyContentInputSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologyContentInputSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologyContentInputSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologyContentInputSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import java.io.InputStream;
+
+import org.apache.stanbol.commons.owl.util.OWLUtils;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An input source that parses an in-memory {@link OWLOntology} object from an input stream.
+ * 
+ * @author alexdma
+ * 
+ */
+public class OntologyContentInputSource extends AbstractOWLOntologyInputSource {
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    public OntologyContentInputSource(InputStream content) throws OWLOntologyCreationException {
+        this(content, OWLManager.createOWLOntologyManager());
+    }
+
+    public OntologyContentInputSource(InputStream content, OWLOntologyManager manager) throws OWLOntologyCreationException {
+        long before = System.currentTimeMillis();
+        bindPhysicalOrigin(null);
+        bindRootOntology(manager.loadOntologyFromOntologyDocument(content));
+        log.debug("Input source initialization completed in {} ms.", (System.currentTimeMillis() - before));
+    }
+
+    @Override
+    public String toString() {
+        return "<ONTOLOGY_CONTENT>" + OWLUtils.extractOntologyID(getRootOntology());
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologySpaceSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologySpaceSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologySpaceSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/OntologySpaceSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OntologySpaceSource extends AbstractOWLOntologyInputSource {
+
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    protected OntologySpace space;
+
+    public OntologySpaceSource(OntologySpace space) {
+        this(space, null);
+    }
+
+    public OntologySpaceSource(OntologySpace space, Set<OntologyInputSource<?>> subtrees) {
+        this.space = space;
+        if (subtrees != null) try {
+            for (OntologyInputSource<?> st : subtrees)
+                appendSubtree(st);
+        } catch (UnmodifiableOntologyCollectorException e) {
+            log.error(
+                "Could not add subtrees to unmodifiable ontology space {}. Input source will have no additions.",
+                e.getOntologyCollector());
+        }
+        bindRootOntology(space.export(OWLOntology.class, false));
+    }
+
+    protected void appendSubtree(OntologyInputSource<?> subtree) throws UnmodifiableOntologyCollectorException {
+        space.addOntology(subtree);
+    }
+
+    public OntologySpace asOntologySpace() {
+        return space;
+    }
+
+    @Override
+    public String toString() {
+        return "SCOPE_ONT_IRI<" + getOrigin() + ">";
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/ParentPathInputSource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/ParentPathInputSource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/ParentPathInputSource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/ParentPathInputSource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import java.io.File;
+
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.apache.stanbol.ontologymanager.servicesapi.io.Origin;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.util.AutoIRIMapper;
+
+/**
+ * An {@link OntologyInputSource} that recursively tries to hijack all import declarations to the directory
+ * containing the input ontology (i.e. to the parent directory of the file itself). It can be used for offline
+ * ontology loading, if one has the entire imports closure available in single directory.<br>
+ * <br>
+ * The behaviour of this class is inherited from the {@link AutoIRIMapper} in the OWL API, and so are its
+ * limitations and fallback policies.
+ * 
+ * @author alexdma
+ * 
+ */
+public class ParentPathInputSource extends AbstractOWLOntologyInputSource {
+
+    /**
+     * Creates a new parent path ontology input source. When created using this constructor, the only active
+     * IRI mapper will be the one that maps to any ontology found in the parent directory of the supplied
+     * file.
+     * 
+     * @param rootFile
+     *            the root ontology file. Must not be a directory.
+     * @throws OWLOntologyCreationException
+     *             if <code>rootFile</code> does not exist, is not an ontology or one of its imports failed to
+     *             load.
+     */
+    public ParentPathInputSource(File rootFile) throws OWLOntologyCreationException {
+        this(rootFile, OWLManager.createOWLOntologyManager());
+    }
+
+    /**
+     * Creates a new parent path ontology input source. If the developer wishes to recycle an
+     * {@link OWLOntologyManager} (e.g. in order to keep the active IRI mappers attached to it), they can do
+     * so by passing it to the method. Please note that recycling ontology managers will increase the
+     * likelihood of {@link OWLOntologyAlreadyExistsException}s being thrown.
+     * 
+     * @param rootFile
+     *            the root ontology file. Must not be a directory.
+     * @param mgr
+     *            the ontology manager to recycle. Note that an {@link AutoIRIMapper} will be added to it.
+     * @throws OWLOntologyCreationException
+     *             if <code>rootFile</code> does not exist, is not an ontology or one of its imports failed to
+     *             load.
+     */
+    public ParentPathInputSource(File rootFile, OWLOntologyManager mgr) throws OWLOntologyCreationException {
+
+        // Directories are not allowed
+        if (rootFile.isDirectory()) throw new IllegalArgumentException(
+                "Could not determine root ontology : file " + rootFile
+                        + " is a directory. Only regular files are allowed.");
+        AutoIRIMapper mapper = new AutoIRIMapper(rootFile.getParentFile(), true);
+        mgr.addIRIMapper(mapper);
+        bindRootOntology(mgr.loadOntologyFromOntologyDocument(rootFile));
+        // TODO : do we really want this to happen?
+        bindPhysicalOrigin(Origin.create(IRI.create(rootFile)));
+    }
+
+    @Override
+    public String toString() {
+        return "ROOT_ONT_IRI<" + getOrigin() + ">";
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologyIRISource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologyIRISource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologyIRISource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologyIRISource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import org.apache.stanbol.ontologymanager.servicesapi.io.Origin;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+/**
+ * An input source that provides the OWL Ontology loaded from the supplied physical IRI, as well as the
+ * physical IRI itself for consumers that need to load the ontology themselves. This means that in order to
+ * use the {@link RootOntologyIRISource}, <i>one</i> the following requirements must be met:
+ * <ol>
+ * <li>Stanbol is in online mode and all imports can be resolved recursively;
+ * <li>Stanbol is in offline mode and the ontology has no recursive import statements.
+ * </ol>
+ * If Stanbol is in offline mode and it is known that all imported ontologies are in the same local directory
+ * as the root ontology, one should use a {@link ParentPathInputSource} instead. <br>
+ * <br>
+ * For convenience, an existing OWL ontology manager can be supplied for loading the ontology.
+ * 
+ * @author alexdma
+ * 
+ */
+public class RootOntologyIRISource extends AbstractOWLOntologyInputSource {
+
+    public RootOntologyIRISource(IRI rootPhysicalIri) throws OWLOntologyCreationException {
+        this(rootPhysicalIri, OWLManager.createOWLOntologyManager());
+    }
+
+    public RootOntologyIRISource(IRI rootPhysicalIri, OWLOntologyManager manager) throws OWLOntologyCreationException {
+        this(rootPhysicalIri, manager, false);
+    }
+
+    public RootOntologyIRISource(IRI rootPhysicalIri, OWLOntologyManager manager, boolean ignoreIriMappers) throws OWLOntologyCreationException {
+        bindPhysicalOrigin(Origin.create(rootPhysicalIri));
+        bindRootOntology(ignoreIriMappers ? manager.loadOntologyFromOntologyDocument(rootPhysicalIri)
+                : manager.loadOntology(rootPhysicalIri));
+    }
+
+    @Override
+    public String toString() {
+        return "ROOT_ONT_IRI<" + getOrigin() + ">";
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologySource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologySource.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologySource.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/main/java/org/apache/stanbol/ontologymanager/sources/owlapi/RootOntologySource.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import org.apache.stanbol.ontologymanager.servicesapi.io.Origin;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+/**
+ * An input source that provides the supplied OWL ontology straight away. The physical IRI is either obtained
+ * from the default document IRI in the ontology, or supplied manually using the appropriate constructor (e.g.
+ * retrieved from the ontology manager that actually loaded the ontology).
+ */
+public class RootOntologySource extends AbstractOWLOntologyInputSource {
+
+    public RootOntologySource(OWLOntology rootOntology) {
+        bindRootOntology(rootOntology);
+        // Never bind logical IDs as physical IRIs, as they risk overwriting previous bindings.
+        bindPhysicalOrigin(null);
+    }
+
+    /**
+     * This constructor can be used to hijack ontologies using a physical IRI other than their default one.
+     * 
+     * @param rootOntology
+     * @param phyicalIRI
+     */
+    public RootOntologySource(OWLOntology rootOntology, IRI phyicalIRI) {
+        this(rootOntology);
+        bindPhysicalOrigin(phyicalIRI == null ? null : Origin.create(phyicalIRI));
+    }
+
+    @Override
+    public String toString() {
+        return "ROOT_ONT<" + rootOntology.getOntologyID() + ">";
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/Constants.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/Constants.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/Constants.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/Constants.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,38 @@
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+public class Constants {
+
+	public static final String PEANUTS_MAIN_BASE = "http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl";
+
+	public static final String PEANUTS_MINOR_BASE = "http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl";
+
+	public static final String dog = "Dog";
+
+	public static final String humanBeing = "HumanBeing";
+
+	public static final String linus = "Linus";
+
+	public static final String lucy = "Lucy";
+
+	public static final String snoopy = "Snoopy";
+
+	public static final String truffles = "Truffles";
+	
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/TestOWLAPIInputSources.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/TestOWLAPIInputSources.java?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/TestOWLAPIInputSources.java (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/test/java/org/apache/stanbol/ontologymanager/sources/owlapi/TestOWLAPIInputSources.java Fri Oct  5 15:35:22 2012
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.sources.owlapi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.Set;
+
+import org.apache.stanbol.commons.owl.OWLOntologyManagerFactory;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.io.WriterDocumentTarget;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLIndividual;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyIRIMapper;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.util.AutoIRIMapper;
+
+public class TestOWLAPIInputSources {
+
+    private static OWLDataFactory df;
+
+    @BeforeClass
+    public static void setUp() {
+        df = OWLManager.getOWLDataFactory();
+    }
+
+    @Test
+    public void testAutoIRIMapper() throws Exception {
+
+        URL url = getClass().getResource("/ontologies");
+        assertNotNull(url);
+        File file = new File(url.toURI());
+        assertTrue(file.exists());
+        assertTrue(file.isDirectory());
+        OWLOntologyIRIMapper mapper = new AutoIRIMapper(file, true);
+
+        IRI dummyiri = IRI.create("http://stanbol.apache.org/ontologies/peanuts/dummycharacters.owl");
+
+        // Cleanup may be required if previous tests have failed.
+        if (mapper.getDocumentIRI(dummyiri) != null) {
+            new File(mapper.getDocumentIRI(dummyiri).toURI()).delete();
+            ((AutoIRIMapper) mapper).update();
+        }
+        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));
+
+        // Create a new ontology in the test resources.
+        OWLOntologyManager mgr = OWLOntologyManagerFactory.createOWLOntologyManager(null);
+        OWLOntology o = mgr.createOntology(dummyiri);
+        File f = new File(URI.create(url.toString() + "/dummycharacters.owl"));
+        mgr.saveOntology(o, new WriterDocumentTarget(new FileWriter(f)));
+        assertTrue(f.exists());
+
+        ((AutoIRIMapper) mapper).update();
+        // The old mapper should be able to locate the new ontology.
+        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));
+
+        // A new mapper too
+        OWLOntologyIRIMapper mapper2 = new AutoIRIMapper(new File(url.toURI()), true);
+        assertFalse(dummyiri.equals(mapper2.getDocumentIRI(dummyiri)));
+
+        // cleanup
+        f.delete();
+    }
+
+    /**
+     * Uses a {@link ParentPathInputSource} to load an ontology importing a modified FOAF, both located in the
+     * same resource directory.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testOfflineImport() throws Exception {
+        URL url = getClass().getResource("/ontologies/maincharacters.owl");
+        assertNotNull(url);
+        File f = new File(url.toURI());
+        assertNotNull(f);
+        OntologyInputSource<OWLOntology> coreSource = new ParentPathInputSource(f);
+
+        // // Check that all the imports closure is made of local files
+        // Set<OWLOntology> closure = coreSource.getImports(true);
+        // for (OWLOntology o : closure)
+        // assertEquals("file", o.getOWLOntologyManager().getOntologyDocumentIRI(o).getScheme());
+
+        assertEquals(coreSource.getRootOntology().getOntologyID().getOntologyIRI(),
+            IRI.create(Constants.PEANUTS_MAIN_BASE));
+        // Linus is stated to be a foaf:Person
+        OWLNamedIndividual iLinus = df.getOWLNamedIndividual(IRI.create(Constants.PEANUTS_MAIN_BASE
+                                                                        + "#Linus"));
+        // Lucy is stated to be a foaf:Perzon
+        OWLNamedIndividual iLucy = df
+                .getOWLNamedIndividual(IRI.create(Constants.PEANUTS_MAIN_BASE + "#Lucy"));
+        OWLClass cPerzon = df.getOWLClass(IRI.create("http://xmlns.com/foaf/0.1/Perzon"));
+
+        Set<OWLIndividual> instances = cPerzon.getIndividuals(coreSource.getRootOntology());
+        assertTrue(!instances.contains(iLinus) && instances.contains(iLucy));
+    }
+
+    /**
+     * Loads a modified FOAF by resolving a URI from a resource directory.
+     * 
+     * @throws Exception
+     */
+    @Test
+    public void testOfflineSingleton() throws Exception {
+        URL url = getClass().getResource("/ontologies/mockfoaf.rdf");
+        assertNotNull(url);
+        OntologyInputSource<OWLOntology> coreSource = new RootOntologyIRISource(IRI.create(url));
+        assertNotNull(df);
+        /*
+         * To check it fetched the correct ontology, we look for a declaration of the bogus class foaf:Perzon
+         * (added in the local FOAF)
+         */
+        OWLClass cPerzon = df.getOWLClass(IRI.create("http://xmlns.com/foaf/0.1/Perzon"));
+        assertTrue(coreSource.getRootOntology().getClassesInSignature().contains(cPerzon));
+    }
+
+}

Added: stanbol/trunk/ontologymanager/sources/owlapi/src/test/resources/ontologies/maincharacters.owl
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/sources/owlapi/src/test/resources/ontologies/maincharacters.owl?rev=1394594&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/sources/owlapi/src/test/resources/ontologies/maincharacters.owl (added)
+++ stanbol/trunk/ontologymanager/sources/owlapi/src/test/resources/ontologies/maincharacters.owl Fri Oct  5 15:35:22 2012
@@ -0,0 +1,102 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!DOCTYPE rdf:RDF [
+    <!ENTITY foaf "http://xmlns.com/foaf/0.1/" >
+    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+]>
+
+
+<rdf:RDF xmlns="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#"
+     xml:base="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl"
+     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+     xmlns:foaf="http://xmlns.com/foaf/0.1/"
+     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#">
+    <owl:Ontology rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl">
+        <rdfs:comment>Should import: http://xmlns.com/foaf/0.1/</rdfs:comment>
+        <owl:versionInfo xml:lang="en">Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
+        </owl:versionInfo>
+        <owl:imports rdf:resource="http://xmlns.com/foaf/0.1/"/>
+    </owl:Ontology>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Annotation properties
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Datatypes
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Individuals
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Linus -->
+
+    <foaf:Person rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Linus">
+        <rdf:type rdf:resource="&owl;NamedIndividual"/>
+        <rdfs:label xml:lang="en">Linus</rdfs:label>
+    </foaf:Person>
+    
+
+
+    <!-- http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Lucy -->
+
+    <foaf:Perzon rdf:about="http://stanbol.apache.org/ontologies/pcomics/maincharacters.owl#Lucy">
+        <rdf:type rdf:resource="&owl;NamedIndividual"/>
+        <rdfs:label xml:lang="en">Lucy</rdfs:label>
+        <rdfs:comment xml:lang="en">The typing of this individual as foaf:Perzon is wilful, DO NOT REMOVE.</rdfs:comment>
+    </foaf:Perzon>
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.2.2.1789) http://owlapi.sourceforge.net -->
+