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/03/26 11:04:49 UTC

svn commit: r1305273 - in /incubator/stanbol/branches/0.9.0-incubating: ./ commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/ data/registries/default/src/main/resources/org/apache/stanbol/data/registries/default/ entityhub/generic/core/src/...

Author: alexdma
Date: Mon Mar 26 09:04:48 2012
New Revision: 1305273

URL: http://svn.apache.org/viewvc?rev=1305273&view=rev
Log:
Merged ontonet fixes from r1303798 to r1303946. Also removed store from ontologymanager POM so that it can build independently

Added:
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOWLUtils.java
      - copied unchanged from r1303946, incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOWLUtils.java
Removed:
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaUtils.java
Modified:
    incubator/stanbol/branches/0.9.0-incubating/   (props changed)
    incubator/stanbol/branches/0.9.0-incubating/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java
    incubator/stanbol/branches/0.9.0-incubating/data/registries/default/src/main/resources/org/apache/stanbol/data/registries/default/stanbol_network.owl
    incubator/stanbol/branches/0.9.0-incubating/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/AbstractEntitySearcher.java   (props changed)
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/pom.xml
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OWLAPIOntologyProvider.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/pom.xml
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/StoredOntologyResource.java
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/index.ftl
    incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/webview.ftl
    incubator/stanbol/branches/0.9.0-incubating/pom.xml
    incubator/stanbol/branches/0.9.0-incubating/reasoners/   (props changed)

Propchange: incubator/stanbol/branches/0.9.0-incubating/
------------------------------------------------------------------------------
  Merged /incubator/stanbol/trunk:r1303785-1303946

Modified: incubator/stanbol/branches/0.9.0-incubating/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java Mon Mar 26 09:04:48 2012
@@ -77,6 +77,15 @@ public class OWLUtils {
         return IRI.create(iri);
     }
 
+    /**
+     * Returns an UriRef wrapper for the first instance of owl:Ontology it detects, and ignores further
+     * instances (which is nonstandard in OWL).
+     * 
+     * If the ontology is anonymous, a timestamped UriRef is created
+     * 
+     * @param g
+     * @return
+     */
     public static UriRef guessOntologyIdentifier(TripleCollection g) {
         Iterator<Triple> it = g.filter(null, RDF.type, OWL.Ontology);
         if (it.hasNext()) {
@@ -85,7 +94,9 @@ public class OWLUtils {
                 "RDF Graph {} has multiple OWL ontology definitions! Ignoring all but {}", g, subj);
             if (subj instanceof UriRef) return (UriRef) subj;
         }
-        return new UriRef(NS_STANBOL + System.currentTimeMillis());
+        String s = NS_STANBOL + System.currentTimeMillis();
+        log.debug("Ontology is anonymous. Returning generated ID <{}> .", s);
+        return new UriRef(s);
     }
 
     public static OWLOntologyID guessOWLOntologyID(TripleCollection g) {

Modified: incubator/stanbol/branches/0.9.0-incubating/data/registries/default/src/main/resources/org/apache/stanbol/data/registries/default/stanbol_network.owl
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/data/registries/default/src/main/resources/org/apache/stanbol/data/registries/default/stanbol_network.owl?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/data/registries/default/src/main/resources/org/apache/stanbol/data/registries/default/stanbol_network.owl (original)
+++ incubator/stanbol/branches/0.9.0-incubating/data/registries/default/src/main/resources/org/apache/stanbol/data/registries/default/stanbol_network.owl Mon Mar 26 09:04:48 2012
@@ -41,7 +41,10 @@ Unless required by applicable law or agr
   <rdf:Description rdf:ID="SocialNetworks">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Social Network Models</rdfs:label>
     <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary"/>
-    <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
+    <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.2</owl:versionInfo>
+    <meta:hasOntology rdf:resource="http://xmlns.com/foaf/spec/index.rdf"/>
+    <meta:hasOntology rdf:resource="http://rdfs.org/sioc/ns"/>
+    <meta:hasOntology rdf:resource="http://purl.org/net/provenance/ns"/>
   </rdf:Description>
   
   <rdf:Description rdf:ID="W3C">
@@ -49,13 +52,27 @@ Unless required by applicable law or agr
     <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary"/>
     <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
     <meta:hasOntology rdf:resource="http://w3.org/ns/org"/>
+    <meta:hasOntology rdf:resource="http://www.w3.org/2004/02/skos/core"/>
+    <meta:hasOntology rdf:resource="http://www.w3.org/2006/time"/>
+  </rdf:Description>
+  
+  <rdf:Description rdf:ID="Foundational">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Foundational</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary"/>
+    <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
   </rdf:Description>
   
   <rdf:Description rdf:ID="GeneralPurposeOntologies">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">General Purpose Ontologies</rdfs:label>
     <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary"/>
-    <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
+    <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.2</owl:versionInfo>
     <meta:hasOntology rdf:resource="http://schema.org/docs/schemaorg.owl"/>
+    <meta:hasOntology rdf:resource="http://www.w3.org/2006/time"/>
+    <meta:hasOntology rdf:resource="http://xmlns.com/foaf/spec/index.rdf"/>
+    <meta:hasOntology rdf:resource="http://w3.org/ns/org"/>
+    <meta:hasOntology rdf:resource="http://purl.org/NET/c4dm/event.owl"/>
+    <meta:hasOntology rdf:resource="http://purl.org/dc/terms/"/>   
+    <meta:hasOntology rdf:resource="http://www.w3.org/2004/02/skos/core"/>
   </rdf:Description>
   
   <rdf:Description rdf:ID="Alignments">
@@ -64,22 +81,63 @@ Unless required by applicable law or agr
     <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
   </rdf:Description>
 
+  <rdf:Description rdf:about="http://www.ontologydesignpatterns.org/ont/dul/DUL.owl">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">DOLCE UltraLite</rdfs:label>
+    <meta:isOntologyOf rdf:resource="#Foundational"/>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
+
   <rdf:Description rdf:about="http://www.ontologydesignpatterns.org/ont/alignments/schemaorg.owl">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Alignments to schema.org</rdfs:label>
     <meta:isOntologyOf rdf:resource="#Alignments"/>
     <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
   </rdf:Description>
 
+  <rdf:Description rdf:about="http://purl.org/dc/elements/1.1/">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Dublin Core metadata schema (legacy)</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
+
+  <rdf:Description rdf:about="http://purl.org/dc/terms/">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Dublin Core metadata schema</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
+
   <rdf:Description rdf:about="http://xmlns.com/foaf/spec/index.rdf">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Friend-Of-A-Friend</rdfs:label>
-    <meta:isOntologyOf rdf:resource="#SocialNetworks"/>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
+  
+  <rdf:Description rdf:about="http://rdfs.org/sioc/ns">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Semantically-Interlinked Online Communities</rdfs:label>
     <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
   </rdf:Description>
 
+  <rdf:Description rdf:about="http://purl.org/NET/c4dm/event.owl">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Event Ontology</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
+  
   <rdf:Description rdf:about="http://w3.org/ns/org">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Organisation Ontology</rdfs:label>
     <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
   </rdf:Description>
+
+  <rdf:Description rdf:about="http://www.w3.org/2004/02/skos/core">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Simple Knowledge Organization System (SKOS)</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+    <meta:isOntologyOf rdf:resource="#Foundational"/>
+  </rdf:Description>
+  
+  <rdf:Description rdf:about="http://purl.org/net/provenance/ns">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Provenance Vocabulary Core Ontology (PVCO)</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
+  
+  <rdf:Description rdf:about="http://www.w3.org/2006/time">
+    <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">OWL-Time</rdfs:label>
+    <rdf:type rdf:resource="http://www.ontologydesignpatterns.org/cpont/codo/codkernel.owl#Ontology"/>
+  </rdf:Description>
   
   <rdf:Description rdf:about="http://schema.org/docs/schemaorg.owl">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Schema.org</rdfs:label>

Propchange: incubator/stanbol/branches/0.9.0-incubating/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/AbstractEntitySearcher.java
------------------------------------------------------------------------------
  Merged /incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/site/AbstractEntitySearcher.java:r1303785-1303946

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/pom.xml?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/pom.xml (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/pom.xml Mon Mar 26 09:04:48 2012
@@ -56,22 +56,14 @@
 						</Bundle-Activator>
 						<Export-Package>
 							org.apache.stanbol.ontologymanager.ontonet.*
-	          			</Export-Package>
+						</Export-Package>
 						<Import-Package>
-							com.hp.hpl.jena.ontology,
-							com.hp.hpl.jena.util,
-							com.hp.hpl.jena.rdf.model,
-							javax.xml.namespace,
-							javax.xml.parsers,
-							javax.xml.xpath,
 							org.apache.clerezza.rdf.core.*,
-							org.w3c.dom,
-							org.xml.sax,
 							org.osgi.*,
 							org.semanticweb.owlapi.*,
 							org.slf4j.*,
 							*
-            			</Import-Package>
+						</Import-Package>
 						<_nouses>true</_nouses>
 					</instructions>
 				</configuration>
@@ -84,6 +76,7 @@
 	</build>
 
 	<dependencies>
+
 		<!-- OSGi deps -->
 		<dependency>
 			<groupId>org.osgi</groupId>
@@ -98,14 +91,8 @@
 			<artifactId>org.apache.felix.scr.annotations</artifactId>
 		</dependency>
 
-		<!-- OWL deps -->
-		<dependency>
-			<groupId>com.hp.hpl.jena</groupId>
-			<artifactId>jena</artifactId>
-		</dependency>
-
 		<!-- Stanbol deps -->
-		<dependency>
+		<dependency> <!-- Used instead of simple graphs for in-memory operations -->
 			<groupId>org.apache.stanbol</groupId>
 			<artifactId>org.apache.stanbol.commons.indexedgraph</artifactId>
 		</dependency>

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java Mon Mar 26 09:04:48 2012
@@ -45,7 +45,9 @@ public interface OntologyCollector exten
     void addListener(OntologyCollectorListener listener);
 
     /**
-     * Adds the given ontology to the ontology space.
+     * Adds the given ontology to the ontology space. If the supplied ontology is not already present in
+     * storage and does not have an OWL version IRI of its own, this ontology collector will 'claim ownership'
+     * of the ontology by setting its own logical ID as the version IRI of the new ontology.
      * 
      * @param ontology
      *            the ontology to be added
@@ -71,25 +73,36 @@ public interface OntologyCollector exten
     /**
      * Returns the ontologies managed by this ontology space.
      * 
-     * @deprecated to obtain the set as {@link OWLOntology} objects, please use
-     *             <code>#getManagedOntologies(OWLOntology.class, boolean)</code>.
-     * 
      * @param withClosure
      *            if true, also the ontologies imported by those directly managed by this space will be
      *            included.
      * @return the set of ontologies in the ontology space
      */
-    Set<OWLOntology> getOntologies(boolean withClosure);
+    <O> Set<O> getManagedOntologies(Class<O> returnType, boolean withClosure);
 
     /**
      * Returns the ontologies managed by this ontology space.
      * 
+     * @deprecated to obtain the set as {@link OWLOntology} objects, please use
+     *             <code>#getManagedOntologies(OWLOntology.class, boolean)</code>.
+     * 
      * @param withClosure
      *            if true, also the ontologies imported by those directly managed by this space will be
      *            included.
      * @return the set of ontologies in the ontology space
      */
-    <O> Set<O> getManagedOntologies(Class<O> returnType, boolean withClosure);
+    Set<OWLOntology> getOntologies(boolean withClosure);
+
+    /**
+     * Equivalent to calling <code>getOntology(IRI, false)</code>;
+     * 
+     * @deprecated to obtain the {@link OWLOntology} object, cast the result of <code>#getOntology(IRI,
+     *             OWLOntology.class)</code> to OWLOntology.
+     * 
+     * @param ontologyIri
+     * @return
+     */
+    OWLOntology getOntology(IRI ontologyIri);
 
     /**
      * Returns the ontology identified by the supplied <i>logical</i> IRI, if such an ontology has been loaded
@@ -108,16 +121,7 @@ public interface OntologyCollector exten
      */
     OWLOntology getOntology(IRI ontologyIri, boolean merge);
 
-    /**
-     * Equivalent to calling <code>getOntology(IRI, false)</code>;
-     * 
-     * @deprecated to obtain the {@link OWLOntology} object, cast the result of <code>#getOntology(IRI,
-     *             OWLOntology.class)</code> to OWLOntology.
-     * 
-     * @param ontologyIri
-     * @return
-     */
-    OWLOntology getOntology(IRI ontologyIri);
+    <O> O getOntology(IRI ontologyIri, Class<O> returnType);
 
     /**
      * TODO replace merge parameter with integer for merge level (-1 for infinite).
@@ -129,18 +133,18 @@ public interface OntologyCollector exten
      */
     <O> O getOntology(IRI ontologyIri, Class<O> returnType, boolean merge);
 
-    <O> O getOntology(IRI ontologyIri, Class<O> returnType);
+    int getOntologyCount();
 
     /**
      * A shortcut method to avoid computing the ontologies themselves before counting them.
      * 
+     * TODO deprecate once support for closure is added to {@link #listManagedOntologies()}.
+     * 
      * @param withClosure
      * @return
      */
     int getOntologyCount(boolean withClosure);
 
-    int getOntologyCount();
-
     /**
      * Determines if the ontology identified by the supplied <i>logical</i> IRI has been loaded in this space.<br>
      * <br>
@@ -155,6 +159,13 @@ public interface OntologyCollector exten
     boolean hasOntology(IRI ontologyIri);
 
     /**
+     * TODO replace with Ontology IDs
+     * 
+     * @return
+     */
+    Set<IRI> listManagedOntologies();
+
+    /**
      * Unregisters the supplied for changes in this ontology space. Has no effect if the same listener was not
      * registered with this ontology space.
      * 
@@ -186,11 +197,4 @@ public interface OntologyCollector exten
      * removing the writelock).
      */
     void tearDown();
-
-    /**
-     * TODO replace with Ontology IDs
-     * 
-     * @return
-     */
-    Set<IRI> listManagedOntologies();
 }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java Mon Mar 26 09:04:48 2012
@@ -43,12 +43,9 @@ import org.apache.stanbol.commons.owl.ut
 public abstract class AbstractClerezzaGraphInputSource extends
         AbstractGenericInputSource<TripleCollection,TcProvider> {
 
-    protected UriRef ontologyId = null;
-
     @Override
     protected void bindRootOntology(TripleCollection ontology) {
         super.bindRootOntology(ontology);
-        this.ontologyId = OWLUtils.guessOntologyIdentifier(ontology);
     }
 
     @Override
@@ -58,7 +55,8 @@ public abstract class AbstractClerezzaGr
 
     protected Set<TripleCollection> getImportedGraphs(TripleCollection g, boolean recursive) {
         Set<TripleCollection> result = new HashSet<TripleCollection>();
-        Iterator<Triple> it = g.filter(OWLUtils.guessOntologyIdentifier((Graph) g), OWL.imports, null);
+        UriRef u = OWLUtils.guessOntologyIdentifier(g);
+        Iterator<Triple> it = g.filter(u, OWL.imports, null);
         while (it.hasNext()) {
             Resource r = it.next().getObject();
             if (r instanceof UriRef) {

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java Mon Mar 26 09:04:48 2012
@@ -27,6 +27,7 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.clerezza.rdf.core.access.TcProvider;
 import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
+import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
 import org.apache.stanbol.commons.owl.util.OWLUtils;
 import org.apache.stanbol.ontologymanager.ontonet.impl.util.OntologyUtils;
 import org.slf4j.Logger;
@@ -41,8 +42,6 @@ import org.slf4j.LoggerFactory;
  */
 public class GraphContentInputSource extends AbstractClerezzaGraphInputSource {
 
-    private UriRef id = null;
-
     private Logger log = LoggerFactory.getLogger(getClass());
 
     /**
@@ -120,11 +119,10 @@ public class GraphContentInputSource ext
         if (tcProvider != null) {
             UriRef name = new UriRef(getClass().getCanonicalName() + "-" + System.currentTimeMillis());
             graph = tcProvider.createMGraph(name);
-        }
+        } else graph = new IndexedMGraph();
         for (String format : formats) {
             try {
-                if (graph != null && graph instanceof MGraph) parser.parse((MGraph) graph, content, format);
-                else graph = parser.parse(content, format);
+                parser.parse((MGraph) graph, content, format);
                 loaded = true;
                 break;
             } catch (UnsupportedFormatException e) {
@@ -137,7 +135,6 @@ public class GraphContentInputSource ext
         }
         if (loaded) {
             bindRootOntology(graph);
-            id = OWLUtils.guessOntologyIdentifier(getRootOntology());
             log.debug("Root ontology is a {}.", getRootOntology().getClass().getCanonicalName());
         }
         log.debug("Input source initialization completed in {} ms.", (System.currentTimeMillis() - before));
@@ -158,7 +155,7 @@ public class GraphContentInputSource ext
 
     @Override
     public String toString() {
-        return "<GRAPH_CONTENT>" + id;
+        return "<GRAPH_CONTENT>" + OWLUtils.guessOntologyIdentifier(getRootOntology());
     }
 
 }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java Mon Mar 26 09:04:48 2012
@@ -24,6 +24,7 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.ImportManagementPolicy;
 import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntologyID;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 
 /**
@@ -169,7 +170,35 @@ public interface OntologyProvider<S> {
      * 
      * @return the supported ontology return types.
      */
-    <O> Class<O>[] getSupportedReturnTypes();
+    Class<?>[] getSupportedReturnTypes();
+
+    boolean hasOntology(IRI ontologyIri);
+
+    /**
+     * Checks if an ontology with the specified OWL ontology ID is in the ontology provider's store.<br>
+     * <br>
+     * Implementations are typically faster than calling {@link #getStoredOntology(IRI, Class)} and checking
+     * if the returned value is not null.
+     * 
+     * @param id
+     *            the ontology id. If there is both an ontology IRI and a version IRI, both must match the
+     *            ontology provider's records in order to return true. Otherwise, it will return true iff
+     *            <i>any</i> match with the ontology IIR is found, no matter its version IRI.
+     * @return true iff an ontology with the supplied id is in the provider's store.
+     */
+    boolean hasOntology(OWLOntologyID id);
+
+    /**
+     * Checks if an ontology with the specified storage reference is in the ontology provider's store.<br>
+     * <br>
+     * Implementations are typically faster than calling {@link #getStoredOntology(String, Class)} and
+     * checking if the returned value is not null.
+     * 
+     * @param key
+     *            the ontology storage key.
+     * @return true iff an ontology with the supplied key is in the provider's store.
+     */
+    boolean hasOntology(String key);
 
     /**
      * Retrieves an ontology by reading its content from a data stream and stores it using the storage system

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java Mon Mar 26 09:04:48 2012
@@ -58,9 +58,11 @@ import org.semanticweb.owlapi.model.OWLO
 import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
 import org.semanticweb.owlapi.model.OWLOntologyChange;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyID;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 import org.semanticweb.owlapi.model.OWLOntologySetProvider;
 import org.semanticweb.owlapi.model.RemoveImport;
+import org.semanticweb.owlapi.model.SetOntologyID;
 import org.semanticweb.owlapi.util.OWLOntologyMerger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -78,7 +80,7 @@ public abstract class AbstractOntologyCo
     public Set<IRI> listManagedOntologies() {
         return managedOntologies;
     }
-    
+
     protected String _id = null;
 
     /**
@@ -150,11 +152,14 @@ public abstract class AbstractOntologyCo
             uri = OWLUtils.guessOntologyIdentifier((TripleCollection) o);
         } else if (o instanceof OWLOntology) {
             uri = new UriRef(OWLUtils.guessOntologyIdentifier((OWLOntology) o).toString());
-        } else throw new UnsupportedOperationException("This ontology space implementation cannot handle "
-                                                       + o.getClass() + " objects.");
+        } else throw new UnsupportedOperationException(
+                "This ontology collector implementation cannot handle " + o.getClass().getCanonicalName()
+                        + " objects.");
 
         // Now for the actual storage. We pass the ontology object directly.
         String key = null;
+        if (ontologyProvider.hasOntology(IRI.create(uri.getUnicodeString()))) if (o instanceof MGraph) claimOwnership((MGraph) o);
+        else if (o instanceof OWLOntology) claimOwnership((OWLOntology) o);
         key = ontologyProvider.loadInStore(o, uri.getUnicodeString(), false);
         /*
          * Actually we are not interested in knowing the key here (ontology collectors are not concerned with
@@ -171,6 +176,49 @@ public abstract class AbstractOntologyCo
         return key;
     }
 
+    protected void claimOwnership(OWLOntology ontology) {
+        log.info("Checking ownership of {} {}", OWLOntology.class.getSimpleName(), ontology.getOntologyID());
+        OWLOntologyID id = ontology.getOntologyID();
+        if (id.getOntologyIRI() != null) {
+            IRI ontologyIRI = id.getOntologyIRI();
+            IRI versionIri = id.getVersionIRI();
+            if (versionIri == null) {
+                log.info("    No OWL version IRI Found . Will set to own ID. ");
+                versionIri = IRI.create(getNamespace() + getID());
+                OWLOntologyID newId = new OWLOntologyID(ontologyIRI, versionIri);
+                OWLOntologyChange change = new SetOntologyID(ontology, newId);
+                ontology.getOWLOntologyManager().applyChange(change);
+                log.info("    Set OWL version IRI : {} . ", versionIri);
+            } else log.info("    Found OWL version IRI {} . Will not claim ownership. ", versionIri);
+        }
+
+    }
+
+    protected void claimOwnership(MGraph ontology) {
+        UriRef owl_viri = new UriRef("http://www.w3.org/2002/07/owl#versionIRI");
+        UriRef ontologyId = null;
+        UriRef versionIri = new UriRef(getNamespace() + getID());
+        Iterator<Triple> it = ontology.filter(null, RDF.type, OWL.Ontology);
+        if (it.hasNext()) {
+            NonLiteral r = it.next().getSubject();
+            if (r instanceof UriRef) ontologyId = (UriRef) r;
+        }
+        log.info("Checking ownership of {} {}", MGraph.class.getSimpleName(), ontologyId != null ? ontologyId
+                : "(anonymous)");
+        if (ontologyId != null) {
+            it = ontology.filter(ontologyId, owl_viri, OWL.Ontology);
+            if (it.hasNext()) {
+                versionIri = (UriRef) it.next().getObject();
+                log.info("    Found OWL version IRI {} . Will not claim ownership. ", versionIri);
+            } else {
+                log.info("    No OWL version IRI Found . Will set to own ID. ");
+                Triple t = new TripleImpl(ontologyId, owl_viri, versionIri);
+                ontology.add(t);
+                log.info("    Set OWL version IRI : {} . ", versionIri);
+            }
+        }
+    }
+
     @Override
     public OWLOntology asOWLOntology(boolean merge) {
         return export(OWLOntology.class, merge);
@@ -496,6 +544,8 @@ public abstract class AbstractOntologyCo
 
             for (Triple t : replaceUs) {
                 String s = ((UriRef) (t.getObject())).getUnicodeString();
+                // FIXME note the different import targets in the OWLOntology and TripleColllection objects!
+                // s = s.substring(s.indexOf("::") + 2, s.length());
                 boolean managed = managedOntologies.contains(IRI.create(s));
                 UriRef target = new UriRef((managed ? ns + "/" + tid + "/" : URIUtils.upOne(ns) + "/") + s);
                 o.remove(t);
@@ -555,7 +605,7 @@ public abstract class AbstractOntologyCo
             for (OWLImportsDeclaration oldImp : o.getImportsDeclarations()) {
                 changes.add(new RemoveImport(o, oldImp));
                 String s = oldImp.getIRI().toString();
-                // s = s.substring(s.indexOf("::") + 2, s.length());
+                s = s.substring(s.indexOf("::") + 2, s.length());
                 boolean managed = managedOntologies.contains(oldImp.getIRI());
                 // For space, always go up at least one
                 IRI ns = getNamespace();
@@ -573,16 +623,16 @@ public abstract class AbstractOntologyCo
     }
 
     @Override
+    public int getOntologyCount() {
+        return getOntologyCount(false);
+    }
+
+    @Override
     public int getOntologyCount(boolean withClosure) {
         if (withClosure) throw new UnsupportedOperationException(
                 "Closure support not implemented efficiently yet. Please call getOntologyCount(false).");
         return managedOntologies.size();
     }
-    
-    @Override
-    public int getOntologyCount() {
-        return getOntologyCount(false);
-    }
 
     @Override
     public Set<Class<?>> getSupportedOntologyTypes() {
@@ -636,7 +686,7 @@ public abstract class AbstractOntologyCo
         if (namespace.toString().endsWith("#")) throw new IllegalArgumentException(
                 "OntoNet namespaces must not end with a hash ('#') character.");
         if (!namespace.toString().endsWith("/")) {
-            log.warn("Namespace {} does not end with slash character ('/'). It will be added automatically.",
+            log.warn("Namespace {} does not end with a slash ('/') character. It be added automatically.",
                 namespace);
             namespace = IRI.create(namespace + "/");
         }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java Mon Mar 26 09:04:48 2012
@@ -39,7 +39,6 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.clerezza.rdf.core.access.EntityAlreadyExistsException;
 import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.access.TcProvider;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
 import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
@@ -55,6 +54,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.felix.scr.annotations.ReferenceStrategy;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
 import org.apache.stanbol.commons.owl.OWLOntologyManagerFactory;
 import org.apache.stanbol.commons.owl.PhonyIRIMapper;
 import org.apache.stanbol.commons.owl.transformation.OWLAPIToClerezzaConverter;
@@ -73,6 +73,7 @@ import org.semanticweb.owlapi.model.OWLD
 import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyChange;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyID;
 import org.semanticweb.owlapi.model.OWLOntologyIRIMapper;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 import org.slf4j.Logger;
@@ -108,6 +109,12 @@ public class ClerezzaOntologyProvider im
 
             static final String _BASE_VOCAB = "http://stanbol.apache.org/ontology/ontonet/meta#";
 
+            static final String ENTRY = _BASE_VOCAB + "Entry";
+
+            static final String HAS_ONTOLOGY_IRI = _BASE_VOCAB + "hasOntologyIRI";
+
+            static final String HAS_VERSION_IRI = _BASE_VOCAB + "hasVersionIRI";
+
             static final String MAPS_TO_GRAPH = _BASE_VOCAB + "mapsToGraph";
 
         }
@@ -125,17 +132,55 @@ public class ClerezzaOntologyProvider im
             }
         }
 
-        void addMapping(IRI ontologyReference, UriRef graphName) {
-            graph.add(new TripleImpl(new UriRef(ontologyReference.toString()), new UriRef(
-                    Vocabulary.MAPS_TO_GRAPH), graphName));
+        void addMapping(OWLOntologyID ontologyReference, UriRef graphName) {
+            if (ontologyReference == null || ontologyReference.isAnonymous()) throw new IllegalArgumentException(
+                    "An anonymous ontology cannot be mapped. A non-anonymous ontology ID must be forged in these cases.");
+            Triple tType, tMaps, tHasOiri = null, tHasViri = null;
+            IRI ontologyIRI = ontologyReference.getOntologyIRI(), versionIri = ontologyReference
+                    .getVersionIRI();
+            UriRef entry = buildResource(ontologyReference);
+            tType = new TripleImpl(entry, RDF.type, new UriRef(Vocabulary.ENTRY));
+            tMaps = new TripleImpl(entry, new UriRef(Vocabulary.MAPS_TO_GRAPH), graphName);
+            tHasOiri = new TripleImpl(entry, new UriRef(Vocabulary.HAS_ONTOLOGY_IRI), new UriRef(
+                    ontologyIRI.toString()));
+            if (versionIri != null) tHasViri = new TripleImpl(entry, new UriRef(Vocabulary.HAS_VERSION_IRI),
+                    new UriRef(versionIri.toString()));
+            graph.add(tType);
+            graph.add(tMaps);
+            if (tHasViri != null) graph.add(tHasViri);
+            graph.add(tHasOiri);
+        }
+
+        private UriRef buildResource(OWLOntologyID ontologyReference) {
+            IRI ontologyIRI = ontologyReference.getOntologyIRI(), versionIri = ontologyReference
+                    .getVersionIRI();
+            UriRef entry = new UriRef(ontologyIRI.toString()
+                                      + ((versionIri == null) ? "" : ("/" + versionIri.toString())));
+            return entry;
+        }
+
+        private OWLOntologyID buildOntologyId(UriRef resource) {
+            IRI oiri = null, viri = null;
+            Iterator<Triple> it = graph.filter(resource, new UriRef(Vocabulary.HAS_ONTOLOGY_IRI), null);
+            if (it.hasNext()) {
+                Resource obj = it.next().getObject();
+                if (obj instanceof UriRef) oiri = IRI.create(((UriRef) obj).getUnicodeString());
+            }
+            it = graph.filter(resource, new UriRef(Vocabulary.HAS_VERSION_IRI), null);
+            if (it.hasNext()) {
+                Resource obj = it.next().getObject();
+                if (obj instanceof UriRef) viri = IRI.create(((UriRef) obj).getUnicodeString());
+            }
+            if (viri == null) return new OWLOntologyID(oiri);
+            else return new OWLOntologyID(oiri, viri);
         }
 
         void clearMappings() {
             graph.clear();
         }
 
-        UriRef getMapping(IRI ontologyReference) {
-            Iterator<Triple> it = graph.filter(new UriRef(ontologyReference.toString()), new UriRef(
+        UriRef getMapping(OWLOntologyID ontologyReference) {
+            Iterator<Triple> it = graph.filter(buildResource(ontologyReference), new UriRef(
                     Vocabulary.MAPS_TO_GRAPH), null);
             while (it.hasNext()) {
                 Resource obj = it.next().getObject();
@@ -144,25 +189,25 @@ public class ClerezzaOntologyProvider im
             return null;
         }
 
-        Set<IRI> keys() {
-            Set<IRI> result = new HashSet<IRI>();
+        Set<OWLOntologyID> keys() {
+            Set<OWLOntologyID> result = new HashSet<OWLOntologyID>();
             Iterator<Triple> it = graph.filter(null, new UriRef(Vocabulary.MAPS_TO_GRAPH), null);
             while (it.hasNext()) {
                 NonLiteral subj = it.next().getSubject();
-                if (subj instanceof UriRef) result.add(IRI.create(((UriRef) subj).getUnicodeString()));
+                if (subj instanceof UriRef) result.add(buildOntologyId((UriRef) subj));
             }
             return result;
         }
 
-        void removeMapping(IRI ontologyReference) {
-            Iterator<Triple> it = graph.filter(new UriRef(ontologyReference.toString()), new UriRef(
+        void removeMapping(OWLOntologyID ontologyReference) {
+            Iterator<Triple> it = graph.filter(buildResource(ontologyReference), new UriRef(
                     Vocabulary.MAPS_TO_GRAPH), null);
             // I expect a concurrent modification exception here, but we'll deal with it later.
             while (it.hasNext())
                 graph.remove(it.next());
         }
 
-        void setMapping(IRI ontologyReference, UriRef graphName) {
+        void setMapping(OWLOntologyID ontologyReference, UriRef graphName) {
             removeMapping(ontologyReference);
             addMapping(ontologyReference, graphName);
         }
@@ -391,7 +436,7 @@ public class ClerezzaOntologyProvider im
     @Override
     public String getKey(IRI ontologyIri) {
         ontologyIri = URIUtils.sanitizeID(ontologyIri);
-        UriRef ur = keymap.getMapping(ontologyIri);
+        UriRef ur = keymap.getMapping(new OWLOntologyID(ontologyIri));
         log.debug("key for {} is {}", ontologyIri, ur);
         return (ur == null) ? null : ur.getUnicodeString();
     }
@@ -467,12 +512,23 @@ public class ClerezzaOntologyProvider im
         return null;
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public Class<?>[] getSupportedReturnTypes() {
         return supported;
     }
 
+    @Override
+    public boolean hasOntology(OWLOntologyID id) {
+        if (id == null || id.isAnonymous()) throw new IllegalArgumentException(
+                "Cannot check for an anonymous ontology.");
+        return keymap.getMapping(id) != null;
+    }
+
+    @Override
+    public boolean hasOntology(String key) {
+        return store.listTripleCollections().contains(new UriRef(key));
+    }
+
     /**
      * Returns <code>true</code> only if Stanbol operates in {@link OfflineMode}.
      * 
@@ -574,8 +630,8 @@ public class ClerezzaOntologyProvider im
 
         long before = System.currentTimeMillis();
 
-        TripleCollection graph;
-        TripleCollection rdfData;
+        TripleCollection graph; // The final graph
+        TripleCollection rdfData; // The supplied ontology converted to TripleCollection
 
         if (ontology instanceof OWLOntology) {
             rdfData = OWLAPIToClerezzaConverter.owlOntologyToClerezzaMGraph((OWLOntology) ontology);
@@ -587,28 +643,34 @@ public class ClerezzaOntologyProvider im
 
         // Force is ignored for the content, but the imports?
 
-        String s = prefix + "::";
+        String s = prefix + "::"; // This will become the graph name
         IRI ontologyIri = null;
 
-        boolean loaded = false;
+        // FIXME Profile this method. Are we getting rid of rdfData after adding its triples?
 
-        // FIXME are we getting rid of rdfData after adding its triples?
+        // preferredKey should be the "guessed" ontology id
         String iri = preferredKey;
-        String alternateId = OWLUtils.guessOntologyIdentifier(rdfData).getUnicodeString();
-        if (iri == null || iri.isEmpty()) iri = alternateId;
-        else try {
-            new UriRef(iri);
+        OWLOntologyID realId = OWLUtils.guessOWLOntologyID(rdfData);
+
+        // String alternateId = OWLUtils.guessOntologyIdentifier(rdfData).getUnicodeString();
+        if ((iri == null || iri.isEmpty()) && realId != null) {
+            if (realId.getOntologyIRI() != null) iri = realId.getOntologyIRI().toString();
+            if (realId.getVersionIRI() != null) iri += ":::" + realId.getVersionIRI().toString();
+        } else try {
+            new UriRef(iri); // Can I make a UriRef from it?
         } catch (Exception ex) {
             iri = OWLUtils.guessOntologyIdentifier(rdfData).getUnicodeString();
         }
 
         ontologyIri = IRI.create(iri);
+        while (s.endsWith("#"))
+            s = s.substring(0, s.length() - 1);
         ontologyIri = URIUtils.sanitizeID(ontologyIri);
         s += ontologyIri;
         // if (s.endsWith("#")) s = s.substring(0, s.length() - 1);
         /*
-         * rdfData should be a SimpleGraph, so we shouldn't have a problem creating one with the TcProvider
-         * and adding triples there, so that the SimpleGraph is garbage-collected.
+         * rdfData should be an in-memory graph, so we shouldn't have a problem creating one with the
+         * TcProvider and adding triples there, so that the in-memory graph is garbage-collected.
          * 
          * TODO this occupies twice as much space, which should not be necessary if the provider is the same
          * as the one used by the input source.
@@ -625,7 +687,10 @@ public class ClerezzaOntologyProvider im
                 else graph = store.createMGraph(uriref);
             }
             graph.addAll(rdfData);
-        } else graph = store.getTriples(uriref);
+        } else {
+            log.debug("Graph with ID {} already in store. Default action is to skip storage.", uriref);
+            graph = store.getTriples(uriref);
+        }
 
         if (resolveImports) {
             // Scan resources of type owl:Ontology, but only get the first.
@@ -646,20 +711,41 @@ public class ClerezzaOntologyProvider im
             }
         }
 
-        loaded = true;
+        // All is already sanitized by the time we get here.
+
+        // Now do the mappings
+        String mappedIds = "";
+        // Discard unconventional ontology IDs with only the version IRI
+        if (realId != null && realId.getOntologyIRI() != null) {
+            // Versioned or not, the real ID mapping is always added
+            keymap.setMapping(realId, uriref);
+            mappedIds += realId;
+            if (realId.getVersionIRI() != null) {
+                // If the unversioned variant of a versioned ID wasn't mapped, map it too.
+                OWLOntologyID unvId = new OWLOntologyID(realId.getOntologyIRI());
+                if (keymap.getMapping(unvId) == null) {
+                    keymap.setMapping(unvId, uriref);
+                    mappedIds += realId;
+                }
+            }
+        }
+        /*
+         * Make an ontology ID out of the originally supplied IRI (which might be the physical one and differ
+         * from the logical one!)
+         * 
+         * If we find out that it differs from the "real ID", we map this one too.
+         * 
+         * TODO how safe is this if there was a mapping earlier?
+         */
+        OWLOntologyID unv = new OWLOntologyID(ontologyIri);
+        if (!unv.equals(realId)) {
+            keymap.setMapping(unv, uriref);
+            mappedIds += " , " + unv;
+        }
+        log.debug("Ontology \n\t\t{}\n\tstored with key\n\t\t{}", mappedIds, s);
+        log.debug("Time: {} ms", (System.currentTimeMillis() - before));
+        return s;
 
-        if (loaded) {
-            // All is already sanitized by the time we get here.
-            UriRef urs = new UriRef(s);
-            keymap.setMapping(ontologyIri, urs);
-            if (alternateId != null && !alternateId.equals(iri)) keymap.setMapping(IRI.create(alternateId),
-                urs);
-            log.debug("Ontology \n\t\t{}\n\tstored with keys\n\t\t{}",
-                ontologyIri + ((alternateId != null && !alternateId.equals(iri)) ? " , " + alternateId : ""),
-                s);
-            log.debug("Time: {} ms", (System.currentTimeMillis() - before));
-            return s;
-        } else return null;
     }
 
     @Override
@@ -737,7 +823,7 @@ public class ClerezzaOntologyProvider im
             }
 
             // FIXME when there's more than one ontology, this way of merging them seems inefficient...
-            TripleCollection tempGraph = new SimpleMGraph();
+            TripleCollection tempGraph = new IndexedMGraph();
             // The set of triples that will be excluded from the merge
             Set<Triple> exclusions = new HashSet<Triple>();
             // Examine all reverse imports
@@ -775,4 +861,9 @@ public class ClerezzaOntologyProvider im
             return OWLAPIToClerezzaConverter.clerezzaGraphToOWLOntology(tempGraph, mgr);
         }
     }
+
+    @Override
+    public boolean hasOntology(IRI ontologyIri) {
+        return hasOntology(new OWLOntologyID(ontologyIri));
+    }
 }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OWLAPIOntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OWLAPIOntologyProvider.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OWLAPIOntologyProvider.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/OWLAPIOntologyProvider.java Mon Mar 26 09:04:48 2012
@@ -29,6 +29,7 @@ import org.semanticweb.owlapi.model.OWLO
 import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 import org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException;
+import org.semanticweb.owlapi.model.OWLOntologyID;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -127,6 +128,16 @@ public class OWLAPIOntologyProvider impl
     }
 
     @Override
+    public boolean hasOntology(OWLOntologyID id) {
+        return store.contains(id);
+    }
+
+    @Override
+    public boolean hasOntology(String key) {
+        return store.contains(IRI.create(key));
+    }
+
+    @Override
     public String loadInStore(InputStream data, String formatIdentifier, String preferredKey, boolean force) {
         try {
             OWLOntology o = store.loadOntologyFromOntologyDocument(data);
@@ -162,4 +173,9 @@ public class OWLAPIOntologyProvider impl
                 "The OWL API implementation does not support import policies other than PRESERVE.");
     }
 
+    @Override
+    public boolean hasOntology(IRI ontologyIri) {
+        return hasOntology(new OWLOntologyID(ontologyIri));
+    }
+
 }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java Mon Mar 26 09:04:48 2012
@@ -55,7 +55,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace.SpaceType;
 import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
-import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaUtils;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOWLUtils;
 import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.OntologySpaceFactoryImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.ScopeRegistryImpl;
 import org.junit.AfterClass;
@@ -103,7 +103,7 @@ public class TestClerezzaSpaces {
         ScopeRegistry reg = new ScopeRegistryImpl();
 
         // This one is created from scratch
-        MGraph ont2 = ClerezzaUtils.createOntology(baseIri2.toString());
+        MGraph ont2 = ClerezzaOWLUtils.createOntology(baseIri2.toString());
         minorSrc = new GraphSource(ont2.getGraph());
         dropSrc = getLocalSource("/ontologies/droppedcharacters.owl");
         nonexSrc = getLocalSource("/ontologies/nonexistentcharacters.owl");

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/pom.xml?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/pom.xml (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/pom.xml Mon Mar 26 09:04:48 2012
@@ -36,7 +36,6 @@
     <module>ontonet</module>
     <module>registry</module>
     <module>web</module>
-    <module>store</module>
     <module>bundlelist</module>
   </modules>
 

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java Mon Mar 26 09:04:48 2012
@@ -21,7 +21,6 @@ import java.util.Set;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
 import org.apache.stanbol.ontologymanager.registry.api.RegistryContentException;
 import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLOntology;
 
 /**
  * An ontology library references one or more ontologies.
@@ -55,9 +54,9 @@ public interface Library extends Registr
      * @throws RegistryContentException
      *             if the requested ontologies have not been loaded.
      */
-    Set<OWLOntology> getOntologies() throws RegistryContentException;
+    <O> Set<O> getOntologies(Class<O> returnType) throws RegistryContentException;
 
-    OWLOntology getOntology(IRI id) throws RegistryContentException;
+    <O> O getOntology(IRI id, Class<O> returnType) throws RegistryContentException;
 
     /**
      * Determines if the contents of this library have been loaded and are up-to-date.

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java Mon Mar 26 09:04:48 2012
@@ -243,10 +243,10 @@ public class RegistryManagerImpl impleme
                     // Relative IRI : use data file provider
                     log.debug("Found relative IRI {} . Will try to retrieve from data file providers.", iri);
                     Map<String,String> info = new HashMap<String,String>();
-                    if (dataFileProvider.isAvailable(null, loc, info)) src = new StreamDocumentSource(
+                    if (dataFileProvider != null && dataFileProvider.isAvailable(null, loc, info)) src = new StreamDocumentSource(
                             dataFileProvider.getInputStream(null, loc, info));
                 }
-                o = mgr.loadOntologyFromOntologyDocument(src, conf);
+                if (src != null) o = mgr.loadOntologyFromOntologyDocument(src, conf);
                 if (o != null) regOnts.add(o);
                 else log.warn("Failed to obtain OWL ontology from resource {}", loc);
             } catch (OWLOntologyAlreadyExistsException e) {

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java Mon Mar 26 09:04:48 2012
@@ -35,7 +35,6 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem;
 import org.apache.stanbol.ontologymanager.registry.api.model.RegistryOntology;
 import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -99,7 +98,7 @@ public class LibraryImpl extends Abstrac
     }
 
     @Override
-    public Set<OWLOntology> getOntologies() throws RegistryContentException {
+    public <O> Set<O> getOntologies(Class<O> returnType) throws RegistryContentException {
         /*
          * Note that this implementation is not synchronized. Listeners may indefinitely be notified before or
          * after the rest of this method is executed. If listeners call loadOntologies(), they could still get
@@ -109,13 +108,10 @@ public class LibraryImpl extends Abstrac
         fireContentRequested(this);
         // If no listener has saved the day by loading the ontologies by now, an exception will be thrown.
         if (!loaded) throw new LibraryContentNotLoadedException(this);
-        Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
+        Set<O> ontologies = new HashSet<O>();
         for (RegistryItem child : getChildren()) {
             if (child instanceof RegistryOntology) {
-                OWLOntology o = (OWLOntology) getCache().getStoredOntology(
-                    ((RegistryOntology) child).getIRI(), OWLOntology.class);
-
-                // OWLOntology o = ((RegistryOntology) child).getRawOntology(this.getIRI());
+                O o = getCache().getStoredOntology(((RegistryOntology) child).getIRI(), returnType);
                 // Should never be null if the library was loaded correctly (an error should have already been
                 // thrown when loading it), but just in case.
                 if (o != null) ontologies.add(o);
@@ -126,7 +122,7 @@ public class LibraryImpl extends Abstrac
     }
 
     @Override
-    public OWLOntology getOntology(IRI id) throws RegistryContentException {
+    public <O> O getOntology(IRI id, Class<O> returnType) throws RegistryContentException {
         /*
          * Note that this implementation is not synchronized. Listeners may indefinitely be notified before or
          * after the rest of this method is executed. If listeners call loadOntologies(), they could still get
@@ -137,12 +133,11 @@ public class LibraryImpl extends Abstrac
         // If no listener has saved the day by loading the ontologies by now, an exception will be thrown.
         if (!loaded) throw new LibraryContentNotLoadedException(this);
 
-        OWLOntology ontology = null;
+        O ontology = null;
 
         RegistryItem child = getChild(id);
         if (child instanceof RegistryOntology) {
-            ontology = (OWLOntology) getCache().getStoredOntology(((RegistryOntology) child).getIRI(),
-                OWLOntology.class);
+            ontology = getCache().getStoredOntology(((RegistryOntology) child).getIRI(), returnType);
         }
         return ontology;
     }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java Mon Mar 26 09:04:48 2012
@@ -153,7 +153,7 @@ public class LibrarySource extends Abstr
         log.debug("Got library {}, expected {}", lib, libraryID);
         // If the manager is set to
         if (lib != null) {
-            Set<OWLOntology> subtrees = lib.getOntologies();
+            Set<OWLOntology> subtrees = lib.getOntologies(OWLOntology.class);
             this.ontologies = subtrees;
 
             for (OWLOntology o : subtrees)

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java Mon Mar 26 09:04:48 2012
@@ -16,8 +16,14 @@
  */
 package org.apache.stanbol.ontologymanager.registry;
 
-import static org.apache.stanbol.ontologymanager.registry.MockOsgiContext.*;
-import static org.junit.Assert.*;
+import static org.apache.stanbol.ontologymanager.registry.MockOsgiContext.parser;
+import static org.apache.stanbol.ontologymanager.registry.MockOsgiContext.reset;
+import static org.apache.stanbol.ontologymanager.registry.MockOsgiContext.tcManager;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -37,6 +43,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.semanticweb.owlapi.model.OWLOntology;
 
 /**
  * Test the correct creation and setup of {@link RegistryManager} implementations.
@@ -126,7 +133,7 @@ public class TestRegistryManager {
         assertNotNull(lib);
 
         // Touch the library. Also test that the listener system works.
-        assertFalse(lib.getOntologies().isEmpty());
+        assertFalse(lib.getOntologies(OWLOntology.class).isEmpty());
     }
 
     /**
@@ -224,7 +231,7 @@ public class TestRegistryManager {
         assertFalse(lib2.isLoaded());
 
         // Touch the library. Also test that the listener system works.
-        assertFalse(lib1.getOntologies().isEmpty());
+        assertFalse(lib1.getOntologies(OWLOntology.class).isEmpty());
         assertTrue(lib1.isLoaded());
         assertFalse(lib2.isLoaded());
     }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/StoredOntologyResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/StoredOntologyResource.java?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/StoredOntologyResource.java (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/StoredOntologyResource.java Mon Mar 26 09:04:48 2012
@@ -119,18 +119,44 @@ public class StoredOntologyResource exte
         /*
          * Export directly to MGraph since the OWLOntologyWriter uses (de-)serializing converters for the
          * other formats.
+         * 
+         * Use oTemp for the "real" graph and o for the graph that will be exported. This is due to the fact
+         * that in o we want to change import statements, but we do not want these changes to be stored
+         * permanently.
          */
-        MGraph o = null;
+        MGraph o = null, oTemp = null;
         try {
-            o = new IndexedMGraph((MGraph) ontologyProvider.getStoredOntology(iri, MGraph.class, merged));
+            oTemp = ontologyProvider.getStoredOntology(iri, MGraph.class, merged);
         } catch (Exception ex) {
             log.warn("Retrieval of ontology with ID " + iri + " failed.", ex);
         }
 
+        if (oTemp == null) {
+            log.debug("Ontology {} missing from provider. Trying libraries...", iri);
+            // See if we can touch a library. TODO: replace with event model on the ontology provider.
+            int minSize = -1;
+            IRI smallest = null;
+            for (Library lib : registryManager.getLibraries(iri)) {
+                int size = lib.getChildren().length;
+                if (minSize < 1 || size < minSize) {
+                    smallest = lib.getIRI();
+                    minSize = size;
+                }
+            }
+            if (smallest != null) {
+                log.debug("Selected library for ontology {} is {} .", iri, smallest);
+                try {
+                    oTemp = registryManager.getLibrary(smallest).getOntology(iri, MGraph.class);
+                } catch (RegistryContentException e) {
+                    log.warn("The content of library " + smallest + " could not be accessed.", e);
+                }
+            }
+        }
+
+        if (oTemp != null) o = new IndexedMGraph(oTemp);
+
         if (o == null) {
-            log.debug(
-                "Ontology {} not found in any ontology provider (and Clerezza triple collections are not yet supported by the registry manager).",
-                iri);
+            log.debug("Ontology {} not found in any ontology provider or library.", iri);
             return Response.status(NOT_FOUND).build();
         }
 
@@ -209,7 +235,7 @@ public class StoredOntologyResource exte
             if (smallest != null) {
                 log.debug("Selected library for ontology {} is {} .", iri, smallest);
                 try {
-                    o = registryManager.getLibrary(smallest).getOntology(iri);
+                    o = registryManager.getLibrary(smallest).getOntology(iri, OWLOntology.class);
                 } catch (RegistryContentException e) {
                     log.warn("The content of library " + smallest + " could not be accessed.", e);
                 }

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/index.ftl?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/index.ftl (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/index.ftl Mon Mar 26 09:04:48 2012
@@ -23,6 +23,7 @@
 	<ul>
 	  <li><a href="${it.publicBaseUri}ontonet/ontology" title="Apache Stanbol OntoNet Scope Manager">Scope Manager</a></li>
 	  <li><a href="${it.publicBaseUri}ontonet/session" title="Apache Stanbol OntoNet Session Manager">Session Manager</a></li>
+	  <li><a href="${it.publicBaseUri}ontonet/registry" title="Apache Stanbol OntoNet Ontology Libraries">Ontology Libraries</a></li>
 	</ul>
 	
     <div class="panel" id="webview"> 

Modified: incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/webview.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/webview.ftl?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/webview.ftl (original)
+++ incubator/stanbol/branches/0.9.0-incubating/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/webview.ftl Mon Mar 26 09:04:48 2012
@@ -18,13 +18,13 @@
   Stanbol OntoNet implements the API section for managing OWL and OWL2 ontologies, in order to prepare them for consumption by reasoning services, refactorers, rule engines and the like. Ontology management in ONM is sparse and not connected: once loaded internally from their remote locations, ontologies live and are known within the realm they were loaded in. This allows loose-coupling and (de-)activation of ontologies in order to scale the data sets for reasoners to process and optimize them for efficiency. The following concepts have been introduced with the ONM:
   <ul>
     <li>
-      <u><em>Ontology scope</em></u>: a "logical realm" for all the ontologies that encompass a certain CMS-related set of concepts (such as "User", "ACL", "Event", "Content", "Domain", "Reengineering", "Community", "Travelling" etc.). Scopes never inherit from each other, though they can load the same ontologies if need be.
+      <u><em>Scope</em></u>: a "logical realm" for all the ontologies that encompass a certain CMS-related set of concepts (such as "User", "ACL", "Event", "Content", "Domain", "Reengineering", "Community", "Travelling" etc.). Scopes never inherit from each other, though they can load the same ontologies if need be.
     </li>
     <li>
-      <u><em>Ontology space</em></u>: an access-restricted container for synchronized access to ontologies within a scope. The ontologies in a scope are loaded within its set of spaces. An ontology scope contains: (a) exactly one <em>core space</em>, which contains the immutable set of essential ontologies that describe the scope; (b) exactly one (possibly empty) <em>custom space</em>, which extends the core space according to specific CMS needs (e.g. the core space for the User scope may contains alignments to FOAF); (c) zero or more <em>session spaces</em>, which extend the custom space with additional models provided by end-users (e.g. the set of individuals that 'populate' a scope may be fed to OntoNet via a session space). Session spaces are mapped one-to-one with KReS sessions (see below).
+      <u><em>Space</em></u>: an access-restricted container for synchronized access to ontologies within a scope. The ontologies in a scope are loaded within its set of spaces. An ontology scope contains: (a) exactly one <em>core space</em>, which contains the immutable set of essential ontologies that describe the scope; (b) exactly one (possibly empty) <em>custom space</em>, which extends the core space according to specific CMS needs (e.g. the core space for the User scope may contains alignments to FOAF).
     </li>
     <li>
-      <em><u>OntoNet session</u></em>: a container of session spaces for all affected scopes, for stateful management of ontology networks. It is not equivalent to an HTTP session (since it can live persistently across multiple HTTP sessions), although its behaviour can reflect the one of the HTTP session that created it, if required by the implementation.
+      <em><u>Session</u></em>: a collector of volatile semantic data, not intended for persistent storage. Sessions can be used for stateful management of ontology networks. It is not equivalent to an HTTP session (since it can live persistently across multiple HTTP sessions), although its behaviour can reflect the one of the HTTP session that created it, if required by the implementation.
     </li>
   </ul>
 </p>

Modified: incubator/stanbol/branches/0.9.0-incubating/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/0.9.0-incubating/pom.xml?rev=1305273&r1=1305272&r2=1305273&view=diff
==============================================================================
--- incubator/stanbol/branches/0.9.0-incubating/pom.xml (original)
+++ incubator/stanbol/branches/0.9.0-incubating/pom.xml Mon Mar 26 09:04:48 2012
@@ -75,10 +75,7 @@
     <module>entityhub</module>
     <module>factstore</module>
 	
-	  <module>ontologymanager/ontonet</module>
-    <module>ontologymanager/registry</module>
-    <module>ontologymanager/web</module>
-    <module>ontologymanager/bundlelist</module>
+	<module>ontologymanager</module>
     <module>rules</module>
     <module>reasoners</module>
   </modules>

Propchange: incubator/stanbol/branches/0.9.0-incubating/reasoners/
------------------------------------------------------------------------------
  Merged /incubator/stanbol/trunk/reasoners:r1303785-1303946