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/08/10 18:29:24 UTC

svn commit: r1371761 [2/3] - in /incubator/stanbol/trunk/ontologymanager: ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/ ontonet/src/main/java/org/ap...

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java Fri Aug 10 16:29:22 2012
@@ -16,21 +16,23 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.impl.clerezza;
 
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.APPENDED_TO;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.ENTRY;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_APPENDED;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_ONTOLOGY_IRI;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_SPACE_CORE;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_SPACE_CUSTOM;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_VERSION_IRI;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_MANAGED_BY;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_SPACE_CORE_OF;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_SPACE_CUSTOM_OF;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MANAGES;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SCOPE;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SESSION;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SPACE;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary._NS_ONTONET;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.APPENDED_TO_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.ENTRY_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_APPENDED_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_ONTOLOGY_IRI_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_SPACE_CORE_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_SPACE_CUSTOM_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_VERSION_IRI_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_MANAGED_BY_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_SPACE_CORE_OF_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_SPACE_CUSTOM_OF_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MANAGES_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MAPS_TO_GRAPH_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.RETRIEVED_FROM_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SCOPE_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SESSION_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SIZE_IN_TRIPLES_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SPACE_URIREF;
 import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary._NS_STANBOL_INTERNAL;
 
 import java.io.IOException;
@@ -59,6 +61,7 @@ import org.apache.clerezza.rdf.core.NonL
 import org.apache.clerezza.rdf.core.Resource;
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.TypedLiteral;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.EntityAlreadyExistsException;
 import org.apache.clerezza.rdf.core.access.TcManager;
@@ -139,20 +142,6 @@ public class ClerezzaOntologyProvider im
      */
     private class OntologyToTcMapper {
 
-        /**
-         * The basic terms to use for the mapping graph.
-         * 
-         * @author alexdma
-         * 
-         */
-        private class Vocabulary {
-
-            static final String MAPS_TO_GRAPH = _NS_ONTONET + "mapsToGraph";
-
-            static final String RETRIEVED_FROM = _NS_ONTONET + "retrievedFrom";
-
-        }
-
         private MGraph graph;
 
         private UriRef graphId = new UriRef(metaGraphId);
@@ -182,11 +171,13 @@ public class ClerezzaOntologyProvider im
             IRI ontologyIRI = ontologyReference.getOntologyIRI(), versionIri = ontologyReference
                     .getVersionIRI();
             UriRef entry = buildResource(ontologyReference);
-            tType = new TripleImpl(entry, RDF.type, ENTRY);
-            tMaps = new TripleImpl(entry, new UriRef(Vocabulary.MAPS_TO_GRAPH), graphName);
-            tHasOiri = new TripleImpl(entry, HAS_ONTOLOGY_IRI, new UriRef(ontologyIRI.toString()));
-            if (versionIri != null) tHasViri = new TripleImpl(entry, HAS_VERSION_IRI, new UriRef(
-                    versionIri.toString()));
+            tType = new TripleImpl(entry, RDF.type, ENTRY_URIREF);
+            tMaps = new TripleImpl(entry, MAPS_TO_GRAPH_URIREF, graphName);
+            LiteralFactory lf = LiteralFactory.getInstance();
+            tHasOiri = new TripleImpl(entry, HAS_ONTOLOGY_IRI_URIREF, lf.createTypedLiteral(new UriRef(
+                    ontologyIRI.toString())));
+            if (versionIri != null) tHasViri = new TripleImpl(entry, HAS_VERSION_IRI_URIREF,
+                    lf.createTypedLiteral(new UriRef(versionIri.toString())));
             synchronized (graph) {
                 graph.add(tType);
                 graph.add(tMaps);
@@ -197,19 +188,26 @@ public class ClerezzaOntologyProvider im
 
         OWLOntologyID buildPublicKey(final UriRef resource) {
             // TODO desanitize?
+            LiteralFactory lf = LiteralFactory.getInstance();
             IRI oiri = null, viri = null;
-            Iterator<Triple> it = graph.filter(resource, HAS_ONTOLOGY_IRI, null);
+            Iterator<Triple> it = graph.filter(resource, HAS_ONTOLOGY_IRI_URIREF, null);
             if (it.hasNext()) {
+                UriRef s = null;
                 Resource obj = it.next().getObject();
-                if (obj instanceof UriRef) oiri = IRI.create(((UriRef) obj).getUnicodeString());
+                if (obj instanceof UriRef) s = ((UriRef) obj);
+                else if (obj instanceof TypedLiteral) s = lf.createObject(UriRef.class, (TypedLiteral) obj);
+                oiri = IRI.create(s.getUnicodeString());
             } else {
                 // Anonymous ontology? Decode the resource itself (which is not null)
                 return OntologyUtils.decode(resource.getUnicodeString());
             }
-            it = graph.filter(resource, HAS_VERSION_IRI, null);
+            it = graph.filter(resource, HAS_VERSION_IRI_URIREF, null);
             if (it.hasNext()) {
+                UriRef s = null;
                 Resource obj = it.next().getObject();
-                if (obj instanceof UriRef) viri = IRI.create(((UriRef) obj).getUnicodeString());
+                if (obj instanceof UriRef) s = ((UriRef) obj);
+                else if (obj instanceof TypedLiteral) s = lf.createObject(UriRef.class, (TypedLiteral) obj);
+                viri = IRI.create(s.getUnicodeString());
             }
             if (viri == null) return new OWLOntologyID(oiri);
             else return new OWLOntologyID(oiri, viri);
@@ -223,20 +221,14 @@ public class ClerezzaOntologyProvider im
          * @return
          */
         UriRef buildResource(OWLOntologyID publicKey) {
-
-            // // The UriRef is of the form ontologyIRI[:::versionIRI] (TODO use something less conventional?)
-            // IRI ontologyIRI = publicKey.getOntologyIRI(), versionIri = publicKey
-            // .getVersionIRI();
-            // UriRef entry = new UriRef(URIUtils.sanitize(ontologyIRI).toString()
-            // + ((versionIri == null) ? "" : (":::" + URIUtils.sanitize(versionIri)
-            // .toString())));
-            // System.out.println("Returning "+entry);
-            // return entry;
-
+            /*
+             * The UriRef is of the form ontologyIRI[:::versionIRI] (TODO use something less conventional e.g.
+             * the string form of OWLOntologyID objects?)
+             */
             TripleCollection meta = getMetaGraph(TripleCollection.class);
             if (publicKey == null) throw new IllegalArgumentException(
                     "Cannot build a UriRef resource on a null public key!");
-            // The UriRef is of the form ontologyIRI[:::versionIRI] (TODO use something less conventional?)
+
             // XXX should versionIRI also include the version IRI set by owners? Currently not
 
             // Remember not to sanitize logical identifiers.
@@ -247,8 +239,11 @@ public class ClerezzaOntologyProvider im
             log.debug("Searching for a meta graph entry for public key:");
             log.debug(" -- {}", publicKey);
             UriRef match = null;
-            for (Iterator<Triple> it = meta
-                    .filter(null, HAS_ONTOLOGY_IRI, new UriRef(ontologyIri.toString())); it.hasNext();) {
+            LiteralFactory lf = LiteralFactory.getInstance();
+            TypedLiteral oiri = lf.createTypedLiteral(new UriRef(ontologyIri.toString()));
+            TypedLiteral viri = versionIri == null ? null : lf.createTypedLiteral(new UriRef(versionIri
+                    .toString()));
+            for (Iterator<Triple> it = meta.filter(null, HAS_ONTOLOGY_IRI_URIREF, oiri); it.hasNext();) {
                 Resource subj = it.next().getSubject();
                 log.debug(" -- Ontology IRI match found. Scanning");
                 log.debug(" -- Resource : {}", subj);
@@ -256,10 +251,9 @@ public class ClerezzaOntologyProvider im
                     log.debug(" ---- (uncomparable: skipping...)");
                     continue;
                 }
-                if (versionIri != null) {
+                if (viri != null) {
                     // Must find matching versionIRI
-                    if (meta.contains(new TripleImpl((UriRef) subj, HAS_VERSION_IRI, new UriRef(versionIri
-                            .toString())))) {
+                    if (meta.contains(new TripleImpl((UriRef) subj, HAS_VERSION_IRI_URIREF, viri))) {
                         log.debug(" ---- Version IRI match!");
                         match = (UriRef) subj;
                         break; // Found
@@ -270,7 +264,7 @@ public class ClerezzaOntologyProvider im
 
                 } else {
                     // Must find unversioned resource
-                    if (meta.filter((UriRef) subj, HAS_VERSION_IRI, null).hasNext()) {
+                    if (meta.filter((UriRef) subj, HAS_VERSION_IRI_URIREF, null).hasNext()) {
                         log.debug(" ---- Unexpected version IRI found. Skipping.");
                         continue;
                     } else {
@@ -289,16 +283,13 @@ public class ClerezzaOntologyProvider im
         }
 
         UriRef getMapping(OWLOntologyID reference) {
-            // UriRef res = buildResource(reference);
-
             Set<UriRef> aliases = new HashSet<UriRef>();
             aliases.add(buildResource(reference));
             for (OWLOntologyID alias : listAliases(reference))
                 aliases.add(buildResource(alias));
-
             for (UriRef alias : aliases) {
                 // Logical mappings first.
-                Iterator<Triple> it = graph.filter(alias, new UriRef(Vocabulary.MAPS_TO_GRAPH), null);
+                Iterator<Triple> it = graph.filter(alias, MAPS_TO_GRAPH_URIREF, null);
                 while (it.hasNext()) {
                     Resource obj = it.next().getObject();
                     if (obj instanceof UriRef) return (UriRef) obj;
@@ -306,7 +297,7 @@ public class ClerezzaOntologyProvider im
                 Literal litloc = LiteralFactory.getInstance().createTypedLiteral(
                     new UriRef(alias.getUnicodeString()));
                 // Logical mappings failed, try physical mappings.
-                it = graph.filter(null, new UriRef(Vocabulary.RETRIEVED_FROM), litloc);
+                it = graph.filter(null, RETRIEVED_FROM_URIREF, litloc);
                 while (it.hasNext()) {
                     Resource obj = it.next().getSubject();
                     if (obj instanceof UriRef) return (UriRef) obj;
@@ -317,7 +308,7 @@ public class ClerezzaOntologyProvider im
 
         OWLOntologyID getReverseMapping(UriRef graphName) {
             // Logical mappings first.
-            Iterator<Triple> it = graph.filter(null, new UriRef(Vocabulary.MAPS_TO_GRAPH), graphName);
+            Iterator<Triple> it = graph.filter(null, MAPS_TO_GRAPH_URIREF, graphName);
             while (it.hasNext()) {
                 Resource obj = it.next().getSubject();
                 if (obj instanceof UriRef) return buildPublicKey((UriRef) obj);
@@ -325,7 +316,7 @@ public class ClerezzaOntologyProvider im
             Literal litloc = LiteralFactory.getInstance().createTypedLiteral(
                 new UriRef(graphName.getUnicodeString()));
             // Logical mappings failed, try physical mappings.
-            it = graph.filter(null, new UriRef(Vocabulary.RETRIEVED_FROM), litloc);
+            it = graph.filter(null, RETRIEVED_FROM_URIREF, litloc);
             while (it.hasNext()) {
                 Resource subj = it.next().getSubject();
                 if (subj instanceof UriRef) return buildPublicKey((UriRef) subj);
@@ -337,16 +328,15 @@ public class ClerezzaOntologyProvider im
         Set<OWLOntologyID> getVersions(IRI ontologyIri) {
             if (ontologyIri == null) throw new IllegalArgumentException("Cannot get versions for a null IRI.");
             Set<OWLOntologyID> keys = new HashSet<OWLOntologyID>();
-            UriRef iri = new UriRef(ontologyIri.toString());
+            LiteralFactory lf = LiteralFactory.getInstance();
+            TypedLiteral iri = lf.createTypedLiteral(new UriRef(ontologyIri.toString()));
             // Exclude aliases.
-            for (Iterator<Triple> it = graph.filter(null, HAS_ONTOLOGY_IRI, iri); it.hasNext();) {
+            for (Iterator<Triple> it = graph.filter(null, HAS_ONTOLOGY_IRI_URIREF, iri); it.hasNext();) {
                 Resource sub = it.next().getSubject();
                 if (sub instanceof UriRef) keys.add(buildPublicKey((UriRef) sub));
             }
             // Also check for physical locations
-            Literal litloc = LiteralFactory.getInstance().createTypedLiteral(iri);
-            for (Iterator<Triple> it = graph.filter(null, new UriRef(Vocabulary.RETRIEVED_FROM), litloc); it
-                    .hasNext();) {
+            for (Iterator<Triple> it = graph.filter(null, RETRIEVED_FROM_URIREF, iri); it.hasNext();) {
                 Resource sub = it.next().getSubject();
                 if (sub instanceof UriRef) keys.add(buildPublicKey((UriRef) sub));
             }
@@ -356,24 +346,22 @@ public class ClerezzaOntologyProvider im
         void mapLocator(IRI locator, UriRef graphName) {
             if (graphName == null) throw new IllegalArgumentException("A null graph name is not allowed.");
             // Null locator is a legal argument, will remove all locator mappings from the supplied graph
-            UriRef retrieved_from = new UriRef(Vocabulary.RETRIEVED_FROM);
             Set<Triple> remove = new HashSet<Triple>();
             for (Iterator<Triple> nodes = graph.filter(graphName, null, null); nodes.hasNext();) {
                 Triple t = nodes.next();
                 // isOntology |= RDF.type.equals(t.getPredicate()) && OWL.Ontology.equals(t.getObject());
-                if (retrieved_from.equals(t.getPredicate())) remove.add(t);
+                if (RETRIEVED_FROM_URIREF.equals(t.getPredicate())) remove.add(t);
             }
             graph.removeAll(remove);
             if (locator != null) {
                 Literal litloc = LiteralFactory.getInstance().createTypedLiteral(
                     new UriRef(locator.toString()));
-                graph.add(new TripleImpl(graphName, retrieved_from, litloc));
+                graph.add(new TripleImpl(graphName, RETRIEVED_FROM_URIREF, litloc));
             }
         }
 
         void removeMapping(OWLOntologyID ontologyReference) {
-            Iterator<Triple> it = graph.filter(buildResource(ontologyReference), new UriRef(
-                    Vocabulary.MAPS_TO_GRAPH), null);
+            Iterator<Triple> it = graph.filter(buildResource(ontologyReference), MAPS_TO_GRAPH_URIREF, null);
             // I expect a concurrent modification exception here, but we'll deal with it later.
             while (it.hasNext())
                 graph.remove(it.next());
@@ -682,7 +670,8 @@ public class ClerezzaOntologyProvider im
         final TripleCollection meta = store.getTriples(new UriRef(metaGraphId));
 
         // Scopes first
-        for (Iterator<Triple> it = meta.filter(null, RDF.type, SCOPE); it.hasNext();) { // for each scope
+        for (Iterator<Triple> it = meta.filter(null, RDF.type, SCOPE_URIREF); it.hasNext();) { // for each
+                                                                                               // scope
             Triple ta = it.next();
             NonLiteral sub = ta.getSubject();
             if (sub instanceof UriRef) {
@@ -691,17 +680,17 @@ public class ClerezzaOntologyProvider im
                 if (s.startsWith(prefix)) {
                     String scopeId = s.substring(prefix.length());
                     log.info("Rebuilding scope \"{}\".", scopeId);
-                    coreOntologies.put(scopeId, new LinkedList<OWLOntologyID>());
-                    customOntologies.put(scopeId, new LinkedList<OWLOntologyID>());
+                    coreOntologies.put(scopeId, new TreeSet<OWLOntologyID>());
+                    customOntologies.put(scopeId, new TreeSet<OWLOntologyID>());
                     UriRef core_ur = null, custom_ur = null;
                     Resource r;
                     // Check core space
-                    Iterator<Triple> it2 = meta.filter(sub, HAS_SPACE_CORE, null);
+                    Iterator<Triple> it2 = meta.filter(sub, HAS_SPACE_CORE_URIREF, null);
                     if (it2.hasNext()) {
                         r = it2.next().getObject();
                         if (r instanceof UriRef) core_ur = (UriRef) r;
                     } else {
-                        it2 = meta.filter(null, IS_SPACE_CORE_OF, sub);
+                        it2 = meta.filter(null, IS_SPACE_CORE_OF_URIREF, sub);
                         if (it2.hasNext()) {
                             r = it2.next().getSubject();
                             if (r instanceof UriRef) core_ur = (UriRef) r;
@@ -709,12 +698,12 @@ public class ClerezzaOntologyProvider im
                     }
 
                     // Check custom space
-                    it2 = meta.filter(sub, HAS_SPACE_CUSTOM, null);
+                    it2 = meta.filter(sub, HAS_SPACE_CUSTOM_URIREF, null);
                     if (it2.hasNext()) {
                         r = it2.next().getObject();
                         if (r instanceof UriRef) custom_ur = (UriRef) r;
                     } else {
-                        it2 = meta.filter(null, IS_SPACE_CUSTOM_OF, sub);
+                        it2 = meta.filter(null, IS_SPACE_CUSTOM_OF_URIREF, sub);
                         if (it2.hasNext()) {
                             r = it2.next().getSubject();
                             if (r instanceof UriRef) custom_ur = (UriRef) r;
@@ -726,7 +715,7 @@ public class ClerezzaOntologyProvider im
                         for (it2 = meta.filter(core_ur, null, null); it2.hasNext();) {
                             Triple t = it2.next();
                             UriRef predicate = t.getPredicate();
-                            if (predicate.equals(MANAGES)) {
+                            if (predicate.equals(MANAGES_URIREF)) {
                                 if (t.getObject() instanceof UriRef) coreOntologies.get(scopeId).add(
                                     keymap.buildPublicKey((UriRef) t.getObject()) // FIXME must be very
                                                                                   // temporary!
@@ -737,7 +726,7 @@ public class ClerezzaOntologyProvider im
                         for (it2 = meta.filter(null, null, core_ur); it2.hasNext();) {
                             Triple t = it2.next();
                             UriRef predicate = t.getPredicate();
-                            if (predicate.equals(IS_MANAGED_BY)) {
+                            if (predicate.equals(IS_MANAGED_BY_URIREF)) {
                                 if (t.getSubject() instanceof UriRef) coreOntologies.get(scopeId).add(
                                     keymap.buildPublicKey((UriRef) t.getSubject()) // FIXME must be very
                                                                                    // temporary!
@@ -750,7 +739,7 @@ public class ClerezzaOntologyProvider im
                         for (it2 = meta.filter(custom_ur, null, null); it2.hasNext();) {
                             Triple t = it2.next();
                             UriRef predicate = t.getPredicate();
-                            if (predicate.equals(MANAGES)) {
+                            if (predicate.equals(MANAGES_URIREF)) {
                                 if (t.getObject() instanceof UriRef) customOntologies.get(scopeId).add(
                                     keymap.buildPublicKey((UriRef) t.getObject()) // FIXME must be very
                                                                                   // temporary!
@@ -761,7 +750,7 @@ public class ClerezzaOntologyProvider im
                         for (it2 = meta.filter(null, null, custom_ur); it2.hasNext();) {
                             Triple t = it2.next();
                             UriRef predicate = t.getPredicate();
-                            if (predicate.equals(IS_MANAGED_BY)) {
+                            if (predicate.equals(IS_MANAGED_BY_URIREF)) {
                                 if (t.getSubject() instanceof UriRef) customOntologies.get(scopeId).add(
                                     keymap.buildPublicKey((UriRef) t.getSubject()) // FIXME must be very
                                                                                    // temporary!
@@ -777,7 +766,8 @@ public class ClerezzaOntologyProvider im
 
         // Sessions next
         Map<String,Collection<OWLOntologyID>> sessionOntologies = new HashMap<String,Collection<OWLOntologyID>>();
-        for (Iterator<Triple> it = meta.filter(null, RDF.type, SESSION); it.hasNext();) { // for each scope
+        for (Iterator<Triple> it = meta.filter(null, RDF.type, SESSION_URIREF); it.hasNext();) { // for each
+                                                                                                 // scope
             Triple ta = it.next();
             NonLiteral sub = ta.getSubject();
             if (sub instanceof UriRef) {
@@ -787,11 +777,11 @@ public class ClerezzaOntologyProvider im
                 if (s.startsWith(prefix)) {
                     String sessionId = s.substring(prefix.length());
                     log.info("Rebuilding session \"{}\".", sessionId);
-                    sessionOntologies.put(sessionId, new HashSet<OWLOntologyID>());
-                    attachedScopes.put(sessionId, new HashSet<String>());
+                    sessionOntologies.put(sessionId, new TreeSet<OWLOntologyID>());
+                    attachedScopes.put(sessionId, new TreeSet<String>());
                     // retrieve the ontologies
                     if (ses_ur != null) {
-                        for (Iterator<Triple> it2 = meta.filter(ses_ur, MANAGES, null); it2.hasNext();) {
+                        for (Iterator<Triple> it2 = meta.filter(ses_ur, MANAGES_URIREF, null); it2.hasNext();) {
                             Resource obj = it2.next().getObject();
                             if (obj instanceof UriRef) sessionOntologies.get(sessionId).add(
                                 keymap.buildPublicKey((UriRef) obj) // FIXME must be very temporary!
@@ -799,7 +789,8 @@ public class ClerezzaOntologyProvider im
                                     );
 
                         }
-                        for (Iterator<Triple> it2 = meta.filter(null, IS_MANAGED_BY, ses_ur); it2.hasNext();) {
+                        for (Iterator<Triple> it2 = meta.filter(null, IS_MANAGED_BY_URIREF, ses_ur); it2
+                                .hasNext();) {
                             Resource subj = it2.next().getSubject();
                             if (subj instanceof UriRef) sessionOntologies.get(sessionId).add(
                                 keymap.buildPublicKey((UriRef) subj) // FIXME must be very temporary!
@@ -807,7 +798,8 @@ public class ClerezzaOntologyProvider im
                                     );
 
                         }
-                        for (Iterator<Triple> it2 = meta.filter(null, APPENDED_TO, ses_ur); it2.hasNext();) {
+                        for (Iterator<Triple> it2 = meta.filter(null, APPENDED_TO_URIREF, ses_ur); it2
+                                .hasNext();) {
                             Resource subj = it2.next().getSubject();
                             if (subj instanceof UriRef) {
                                 String s1 = ((UriRef) subj).getUnicodeString();
@@ -818,7 +810,8 @@ public class ClerezzaOntologyProvider im
                                 }
                             }
                         }
-                        for (Iterator<Triple> it2 = meta.filter(ses_ur, HAS_APPENDED, null); it2.hasNext();) {
+                        for (Iterator<Triple> it2 = meta.filter(ses_ur, HAS_APPENDED_URIREF, null); it2
+                                .hasNext();) {
                             Resource obj = it2.next().getObject();
                             if (obj instanceof UriRef) {
                                 String s1 = ((UriRef) obj).getUnicodeString();
@@ -1168,9 +1161,8 @@ public class ClerezzaOntologyProvider im
             // mappedIds += realId;
             // }
             // }
-            Triple t = new TripleImpl(keymap.buildResource(publicKey),
-                    org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SIZE_IN_TRIPLES, LiteralFactory
-                            .getInstance().createTypedLiteral(Integer.valueOf(rdfData.size())));
+            Triple t = new TripleImpl(keymap.buildResource(publicKey), SIZE_IN_TRIPLES_URIREF, LiteralFactory
+                    .getInstance().createTypedLiteral(Integer.valueOf(rdfData.size())));
             getMetaGraph(MGraph.class).add(t);
 
         }
@@ -1456,14 +1448,14 @@ public class ClerezzaOntologyProvider im
         // If this method was called after a scope rebuild, the following will have little to no effect.
         synchronized (meta) {
             // Spaces are created along with the scope, so it is safe to add their triples.
-            meta.add(new TripleImpl(scopeur, RDF.type, SCOPE));
-            meta.add(new TripleImpl(coreur, RDF.type, SPACE));
-            meta.add(new TripleImpl(custur, RDF.type, SPACE));
-            meta.add(new TripleImpl(scopeur, HAS_SPACE_CORE, coreur));
-            meta.add(new TripleImpl(scopeur, HAS_SPACE_CUSTOM, custur));
+            meta.add(new TripleImpl(scopeur, RDF.type, SCOPE_URIREF));
+            meta.add(new TripleImpl(coreur, RDF.type, SPACE_URIREF));
+            meta.add(new TripleImpl(custur, RDF.type, SPACE_URIREF));
+            meta.add(new TripleImpl(scopeur, HAS_SPACE_CORE_URIREF, coreur));
+            meta.add(new TripleImpl(scopeur, HAS_SPACE_CUSTOM_URIREF, custur));
             // Add inverse predicates so we can traverse the graph in both directions.
-            meta.add(new TripleImpl(coreur, IS_SPACE_CORE_OF, scopeur));
-            meta.add(new TripleImpl(custur, IS_SPACE_CUSTOM_OF, scopeur));
+            meta.add(new TripleImpl(coreur, IS_SPACE_CORE_OF_URIREF, scopeur));
+            meta.add(new TripleImpl(custur, IS_SPACE_CUSTOM_OF_URIREF, scopeur));
         }
         log.debug("Ontology collector information triples added for scope \"{}\".", scope);
     }
@@ -1485,7 +1477,7 @@ public class ClerezzaOntologyProvider im
         for (Iterator<Triple> it = meta.filter(scopeur, null, null); it.hasNext();) {
             Triple t = it.next();
             if (RDF.type.equals(t.getPredicate())) {
-                if (SCOPE.equals(t.getObject())) removable = true;
+                if (SCOPE_URIREF.equals(t.getObject())) removable = true;
                 else conflict = true;
             }
             removeUs.add(t);
@@ -1493,7 +1485,7 @@ public class ClerezzaOntologyProvider im
         if (!removable) {
             log.error("Cannot write scope deregistration to persistence:");
             log.error("-- resource {}", scopeur);
-            log.error("-- is not typed as a {} in the meta-graph.", SCOPE);
+            log.error("-- is not typed as a {} in the meta-graph.", SCOPE_URIREF);
         } else if (conflict) {
             log.error("Conflict upon scope deregistration:");
             log.error("-- resource {}", scopeur);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CoreSpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CoreSpaceImpl.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CoreSpaceImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CoreSpaceImpl.java Fri Aug 10 16:29:22 2012
@@ -38,6 +38,17 @@ public class CoreSpaceImpl extends Abstr
         super(buildId(scopeID), namespace, SpaceType.CORE, ontologyProvider);
     }
 
+    @Override
+    public boolean equals(Object arg0) {
+        if (arg0 == null) return false;
+        if (!(arg0 instanceof CoreOntologySpace)) return false;
+        if (this == arg0) return true;
+        log.warn(
+            "{} only implements weak equality, i.e. managed ontologies are only checked by public key, not by content.",
+            getClass());
+        return super.equals(arg0);
+    }
+
     /**
      * When set up, a core space is write-locked.
      */

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CustomSpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CustomSpaceImpl.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CustomSpaceImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CustomSpaceImpl.java Fri Aug 10 16:29:22 2012
@@ -56,6 +56,18 @@ public class CustomSpaceImpl extends Abs
     }
 
     @Override
+    public boolean equals(Object arg0) {
+        if (arg0 == null) return false;
+        if (!(arg0 instanceof CustomOntologySpace)) return false;
+        if (this == arg0) return true;
+        log.warn(
+            "{} only implements weak equality, i.e. managed ontologies are only checked by public key, not by content.",
+            getClass());
+        CustomOntologySpace sp = (CustomOntologySpace) arg0;
+        return super.equals(arg0) && this.getConnectivityPolicy().equals(sp.getConnectivityPolicy());
+    }
+
+    @Override
     public ConnectivityPolicy getConnectivityPolicy() {
         return policy;
     }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/MGraphNetworkMultiplexer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/MGraphNetworkMultiplexer.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/MGraphNetworkMultiplexer.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/MGraphNetworkMultiplexer.java Fri Aug 10 16:29:22 2012
@@ -16,15 +16,15 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.impl.clerezza;
 
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.APPENDED_TO;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.ENTRY;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_APPENDED;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_ONTOLOGY_IRI;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_VERSION_IRI;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_MANAGED_BY;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MANAGES;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SESSION;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SIZE_IN_TRIPLES;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.APPENDED_TO_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.ENTRY_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_APPENDED_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_ONTOLOGY_IRI_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.HAS_VERSION_IRI_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_MANAGED_BY_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MANAGES_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SESSION_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.SIZE_IN_TRIPLES_URIREF;
 import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary._NS_STANBOL_INTERNAL;
 
 import java.util.HashSet;
@@ -32,9 +32,11 @@ import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.clerezza.rdf.core.Literal;
+import org.apache.clerezza.rdf.core.LiteralFactory;
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.Resource;
 import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.TypedLiteral;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
 import org.apache.clerezza.rdf.ontologies.RDF;
@@ -95,18 +97,20 @@ public class MGraphNetworkMultiplexer im
     protected OWLOntologyID buildPublicKey(final UriRef resource) {
         // TODO desanitize?
         IRI oiri = null, viri = null;
-        Iterator<Triple> it = meta.filter(resource, HAS_ONTOLOGY_IRI, null);
+        Iterator<Triple> it = meta.filter(resource, HAS_ONTOLOGY_IRI_URIREF, null);
         if (it.hasNext()) {
             Resource obj = it.next().getObject();
             if (obj instanceof UriRef) oiri = IRI.create(((UriRef) obj).getUnicodeString());
+            else if (obj instanceof Literal) oiri = IRI.create(((Literal) obj).getLexicalForm());
         } else {
             // Anonymous ontology? Decode the resource itself (which is not null)
             return OntologyUtils.decode(resource.getUnicodeString());
         }
-        it = meta.filter(resource, HAS_VERSION_IRI, null);
+        it = meta.filter(resource, HAS_VERSION_IRI_URIREF, null);
         if (it.hasNext()) {
             Resource obj = it.next().getObject();
             if (obj instanceof UriRef) viri = IRI.create(((UriRef) obj).getUnicodeString());
+            else if (obj instanceof Literal) viri = IRI.create(((Literal) obj).getLexicalForm());
         }
         if (viri == null) return new OWLOntologyID(oiri);
         else return new OWLOntologyID(oiri, viri);
@@ -130,12 +134,14 @@ public class MGraphNetworkMultiplexer im
         IRI ontologyIri = publicKey.getOntologyIRI(), versionIri = publicKey.getVersionIRI();
         if (ontologyIri == null) throw new IllegalArgumentException(
                 "Cannot build a UriRef resource on an anonymous public key!");
-
         log.debug("Searching for a meta graph entry for public key:");
         log.debug(" -- {}", publicKey);
         UriRef match = null;
-        for (Iterator<Triple> it = meta.filter(null, HAS_ONTOLOGY_IRI, new UriRef(ontologyIri.toString())); it
-                .hasNext();) {
+        LiteralFactory lf = LiteralFactory.getInstance();
+        TypedLiteral oiri = lf.createTypedLiteral(new UriRef(ontologyIri.toString()));
+        TypedLiteral viri = versionIri == null ? null : lf.createTypedLiteral(new UriRef(versionIri
+                .toString()));
+        for (Iterator<Triple> it = meta.filter(null, HAS_ONTOLOGY_IRI_URIREF, oiri); it.hasNext();) {
             Resource subj = it.next().getSubject();
             log.debug(" -- Ontology IRI match found. Scanning");
             log.debug(" -- Resource : {}", subj);
@@ -143,10 +149,9 @@ public class MGraphNetworkMultiplexer im
                 log.debug(" ---- (uncomparable: skipping...)");
                 continue;
             }
-            if (versionIri != null) {
+            if (viri != null) {
                 // Must find matching versionIRI
-                if (meta.contains(new TripleImpl((UriRef) subj, HAS_VERSION_IRI, new UriRef(versionIri
-                        .toString())))) {
+                if (meta.contains(new TripleImpl((UriRef) subj, HAS_VERSION_IRI_URIREF, viri))) {
                     log.debug(" ---- Version IRI match!");
                     match = (UriRef) subj;
                     break; // Found
@@ -157,7 +162,7 @@ public class MGraphNetworkMultiplexer im
 
             } else {
                 // Must find unversioned resource
-                if (meta.filter((UriRef) subj, HAS_VERSION_IRI, null).hasNext()) {
+                if (meta.filter((UriRef) subj, HAS_VERSION_IRI_URIREF, null).hasNext()) {
                     log.debug(" ---- Unexpected version IRI found. Skipping.");
                     continue;
                 } else {
@@ -193,7 +198,7 @@ public class MGraphNetworkMultiplexer im
     @Override
     public Set<OWLOntologyID> getPublicKeys() {
         Set<OWLOntologyID> result = new HashSet<OWLOntologyID>();
-        Iterator<Triple> it = meta.filter(null, RDF.type, ENTRY);
+        Iterator<Triple> it = meta.filter(null, RDF.type, ENTRY_URIREF);
         while (it.hasNext()) {
             Resource obj = it.next().getSubject();
             if (obj instanceof UriRef) result.add(buildPublicKey((UriRef) obj));
@@ -204,7 +209,7 @@ public class MGraphNetworkMultiplexer im
     @Override
     public int getSize(OWLOntologyID publicKey) {
         UriRef subj = buildResource(publicKey);
-        Iterator<Triple> it = meta.filter(subj, SIZE_IN_TRIPLES, null);
+        Iterator<Triple> it = meta.filter(subj, SIZE_IN_TRIPLES_URIREF, null);
         if (it.hasNext()) {
             Resource obj = it.next().getObject();
             if (obj instanceof Literal) {
@@ -242,11 +247,11 @@ public class MGraphNetworkMultiplexer im
         boolean hasValues = false;
         log.debug("Ontology {}", addedOntology);
         log.debug("-- is already managed by the following collectors :");
-        for (Iterator<Triple> it = meta.filter(u, IS_MANAGED_BY, null); it.hasNext();) {
+        for (Iterator<Triple> it = meta.filter(u, IS_MANAGED_BY_URIREF, null); it.hasNext();) {
             hasValues = true;
             log.debug("-- {}", it.next().getObject());
         }
-        for (Iterator<Triple> it = meta.filter(null, MANAGES, u); it.hasNext();) {
+        for (Iterator<Triple> it = meta.filter(null, MANAGES_URIREF, u); it.hasNext();) {
             hasValues = true;
             log.debug("-- {} (inverse)", it.next().getSubject());
         }
@@ -255,12 +260,12 @@ public class MGraphNetworkMultiplexer im
         // Add both inverse triples. This graph has to be traversed efficiently, no need for reasoners.
         UriRef predicate1 = null, predicate2 = null;
         if (collector instanceof OntologySpace) {
-            predicate1 = MANAGES;
-            predicate2 = IS_MANAGED_BY;
+            predicate1 = MANAGES_URIREF;
+            predicate2 = IS_MANAGED_BY_URIREF;
         } else if (collector instanceof Session) {
             // TODO implement model for sessions.
-            predicate1 = MANAGES;
-            predicate2 = IS_MANAGED_BY;
+            predicate1 = MANAGES_URIREF;
+            predicate2 = IS_MANAGED_BY_URIREF;
         } else {
             log.error("Unrecognized ontology collector type {} for \"{}\". Aborting.", collector.getClass(),
                 collector.getID());
@@ -303,7 +308,7 @@ public class MGraphNetworkMultiplexer im
         for (Iterator<Triple> it = meta.filter(c, null, u); it.hasNext();) {
             UriRef property = it.next().getPredicate();
             if (collector instanceof OntologySpace || collector instanceof Session) {
-                if (property.equals(MANAGES)) badState = false;
+                if (property.equals(MANAGES_URIREF)) badState = false;
             }
         }
 
@@ -311,7 +316,7 @@ public class MGraphNetworkMultiplexer im
         for (Iterator<Triple> it = meta.filter(u, null, c); it.hasNext();) {
             UriRef property = it.next().getPredicate();
             if (collector instanceof OntologySpace || collector instanceof Session) {
-                if (property.equals(IS_MANAGED_BY)) badState = false;
+                if (property.equals(IS_MANAGED_BY_URIREF)) badState = false;
             }
         }
 
@@ -320,8 +325,8 @@ public class MGraphNetworkMultiplexer im
 
         synchronized (meta) {
             if (collector instanceof OntologySpace) {
-                meta.remove(new TripleImpl(c, MANAGES, u));
-                meta.remove(new TripleImpl(u, IS_MANAGED_BY, c));
+                meta.remove(new TripleImpl(c, MANAGES_URIREF, u));
+                meta.remove(new TripleImpl(u, IS_MANAGED_BY_URIREF, c));
             }
         }
     }
@@ -332,8 +337,8 @@ public class MGraphNetworkMultiplexer im
         if (sessionur == null || scopeur == null) throw new IllegalArgumentException(
                 "UriRefs for scope and session cannot be null.");
         if (meta instanceof MGraph) synchronized (meta) {
-            meta.add(new TripleImpl(sessionur, HAS_APPENDED, scopeur));
-            meta.add(new TripleImpl(scopeur, APPENDED_TO, sessionur));
+            meta.add(new TripleImpl(sessionur, HAS_APPENDED_URIREF, scopeur));
+            meta.add(new TripleImpl(scopeur, APPENDED_TO_URIREF, sessionur));
         }
     }
 
@@ -344,8 +349,8 @@ public class MGraphNetworkMultiplexer im
                 "UriRefs for scope and session cannot be null.");
         if (meta instanceof MGraph) synchronized (meta) {
             // TripleImpl implements equals() and hashCode() ...
-            meta.remove(new TripleImpl(sessionur, HAS_APPENDED, scopeur));
-            meta.remove(new TripleImpl(scopeur, APPENDED_TO, sessionur));
+            meta.remove(new TripleImpl(sessionur, HAS_APPENDED_URIREF, scopeur));
+            meta.remove(new TripleImpl(scopeur, APPENDED_TO_URIREF, sessionur));
         }
     }
 
@@ -368,7 +373,7 @@ public class MGraphNetworkMultiplexer im
         // If this method was called after a session rebuild, the following will have little to no effect.
         synchronized (meta) {
             // The only essential triple to add is typing
-            meta.add(new TripleImpl(sesur, RDF.type, SESSION));
+            meta.add(new TripleImpl(sesur, RDF.type, SESSION_URIREF));
         }
         log.debug("Ontology collector information triples added for session \"{}\".", sesur);
     }
@@ -381,7 +386,7 @@ public class MGraphNetworkMultiplexer im
         for (Iterator<Triple> it = meta.filter(sessionur, null, null); it.hasNext();) {
             Triple t = it.next();
             if (RDF.type.equals(t.getPredicate())) {
-                if (SESSION.equals(t.getObject())) removable = true;
+                if (SESSION_URIREF.equals(t.getObject())) removable = true;
                 else conflict = true;
             }
             removeUs.add(t);
@@ -389,7 +394,7 @@ public class MGraphNetworkMultiplexer im
         if (!removable) {
             log.error("Cannot write session deregistration to persistence:");
             log.error("-- resource {}", sessionur);
-            log.error("-- is not typed as a {} in the meta-graph.", SESSION);
+            log.error("-- is not typed as a {} in the meta-graph.", SESSION_URIREF);
         } else if (conflict) {
             log.error("Conflict upon session deregistration:");
             log.error("-- resource {}", sessionur);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java Fri Aug 10 16:29:22 2012
@@ -27,7 +27,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.OntologyCollectorListener;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.UnmodifiableOntologyCollectorException;
-import org.apache.stanbol.ontologymanager.ontonet.api.io.OriginOrInputSource;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.CoreOntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.CustomOntologySpace;
@@ -110,10 +110,10 @@ public class OntologySpaceFactoryImpl im
      * @param scopeID
      * @param rootSource
      */
-    private void configureSpace(OntologySpace s, String scopeID, OriginOrInputSource... ontologySources) {
+    private void configureSpace(OntologySpace s, String scopeID, OntologyInputSource<?>... ontologySources) {
         configureSpace(s, scopeID);
         if (ontologySources != null) try {
-            for (OriginOrInputSource src : ontologySources)
+            for (OntologyInputSource<?> src : ontologySources)
                 s.addOntology(src);
         } catch (UnmodifiableOntologyCollectorException e) {
             log.error("Ontology space " + s.getID() + " was found locked at creation time!", e);
@@ -122,14 +122,15 @@ public class OntologySpaceFactoryImpl im
     }
 
     @Override
-    public CoreOntologySpace createCoreOntologySpace(String scopeId, OriginOrInputSource... coreSources) {
+    public CoreOntologySpace createCoreOntologySpace(String scopeId, OntologyInputSource<?>... coreSources) {
         CoreOntologySpace s = new CoreSpaceImpl(scopeId, namespace, ontologyProvider);
         configureSpace(s, scopeId, coreSources);
         return s;
     }
 
     @Override
-    public CustomOntologySpace createCustomOntologySpace(String scopeId, OriginOrInputSource... customSources) {
+    public CustomOntologySpace createCustomOntologySpace(String scopeId,
+                                                         OntologyInputSource<?>... customSources) {
         CustomOntologySpace s = new CustomSpaceImpl(scopeId, namespace, ontologyProvider);
         configureSpace(s, scopeId, customSources);
         return s;
@@ -138,7 +139,7 @@ public class OntologySpaceFactoryImpl im
     @Override
     public OntologySpace createOntologySpace(String scopeId,
                                              SpaceType type,
-                                             OriginOrInputSource... ontologySources) {
+                                             OntologyInputSource<?>... ontologySources) {
         switch (type) {
             case CORE:
                 return createCoreOntologySpace(scopeId, ontologySources);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java Fri Aug 10 16:29:22 2012
@@ -37,7 +37,7 @@ import org.apache.clerezza.rdf.ontologie
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.OntologyCollector;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.OntologyCollectorListener;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.UnmodifiableOntologyCollectorException;
-import org.apache.stanbol.ontologymanager.ontonet.api.io.OriginOrInputSource;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.CoreOntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.CustomOntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
@@ -96,11 +96,11 @@ public class OntologyScopeImpl implement
     public OntologyScopeImpl(String id,
                              IRI namespace,
                              OntologySpaceFactory factory,
-                             OriginOrInputSource... coreOntologies) {
+                             OntologyInputSource<?>... coreOntologies) {
         setID(id);
-        setNamespace(namespace);
+        setDefaultNamespace(namespace);
         configureCoreSpace(factory);
-        for (OriginOrInputSource src : coreOntologies)
+        for (OntologyInputSource<?> src : coreOntologies)
             this.coreSpace.addOntology(src);
         // let's just lock it. Once the core space is done it's done.
         this.coreSpace.setUp();
@@ -138,6 +138,16 @@ public class OntologyScopeImpl implement
     }
 
     @Override
+    public boolean equals(Object arg0) {
+        if (arg0 == null) return false;
+        if (!(arg0 instanceof OntologyScope)) return false;
+        OntologyScope sc = (OntologyScope) arg0;
+        return this.getID().equals(sc.getID()) && this.getDefaultNamespace().equals(sc.getDefaultNamespace())
+               && this.getCoreSpace().equals(sc.getCoreSpace())
+               && this.getCustomSpace().equals(sc.getCustomSpace());
+    }
+
+    @Override
     public <O> O export(Class<O> returnType, boolean merge) {
         return export(returnType, merge, getDefaultNamespace());
     }
@@ -382,8 +392,6 @@ public class OntologyScopeImpl implement
      *            only allows non-null and non-empty IRIs, with no query or fragment. Hash URIs are not
      *            allowed, slash URIs are preferred. If neither, a slash will be concatenated and a warning
      *            will be logged.
-     * 
-     * @see OntologyScope#setNamespace(IRI)
      */
     @Override
     public void setDefaultNamespace(IRI namespace) {

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/renderers/ScopeSetRenderer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/renderers/ScopeSetRenderer.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/renderers/ScopeSetRenderer.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/renderers/ScopeSetRenderer.java Fri Aug 10 16:29:22 2012
@@ -48,7 +48,7 @@ public class ScopeSetRenderer {
 
     private static OWLDataFactory __factory = OWLManager.getOWLDataFactory();
 
-    private static IRI _scopeIri = IRI.create(Vocabulary.SCOPE.getUnicodeString());
+    private static IRI _scopeIri = IRI.create(Vocabulary.SCOPE_URIREF.getUnicodeString());
 
     private static OWLClass cScope = __factory.getOWLClass(_scopeIri);
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionImpl.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionImpl.java Fri Aug 10 16:29:22 2012
@@ -111,6 +111,20 @@ public class SessionImpl extends Abstrac
     }
 
     @Override
+    public boolean equals(Object arg0) {
+        if (arg0 == null) return false;
+        if (!(arg0 instanceof Session)) return false;
+        if (this == arg0) return true;
+        log.warn(
+            "{} only implements weak equality, i.e. managed ontologies are only checked by public key, not by content.",
+            getClass());
+        Session coll = (Session) arg0;
+        return super.equals(arg0) && this.getAttachedScopes().equals(coll.getAttachedScopes())
+               && this.getAttachedScopes().equals(coll.getAttachedScopes())
+               && this.getSessionState().equals(coll.getSessionState());
+    }
+
+    @Override
     protected MGraph exportToMGraph(boolean merge, IRI universalPrefix) {
         MGraph mg = super.exportToMGraph(merge, universalPrefix);
         // Add import declarations for attached scopes.

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java Fri Aug 10 16:29:22 2012
@@ -36,7 +36,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.OntologyNetworkConfiguration;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.MissingOntologyException;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.OntologyCollectorListener;
-import org.apache.stanbol.ontologymanager.ontonet.api.io.Origin;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.StoredOntologySource;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyNetworkMultiplexer;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
@@ -183,11 +183,11 @@ public class SessionManagerImpl implemen
         if (id == null) id = _ID_DEFAULT;
         String s = null;
         try {
-            setNamespace(offline.getDefaultOntologyNetworkNamespace());
+            setDefaultNamespace(offline.getDefaultOntologyNetworkNamespace());
         } catch (Exception e) {
             log.warn("Invalid namespace {}. Setting to default value {}",
                 offline.getDefaultOntologyNetworkNamespace(), _ONTOLOGY_NETWORK_NS_DEFAULT);
-            setNamespace(IRI.create(_ONTOLOGY_NETWORK_NS_DEFAULT));
+            setDefaultNamespace(IRI.create(_ONTOLOGY_NETWORK_NS_DEFAULT));
         }
         try {
             s = (String) configuration.get(SessionManager.MAX_ACTIVE_SESSIONS);
@@ -383,9 +383,7 @@ public class SessionManagerImpl implemen
             session.setActive(false); // Restored sessions are inactive at first.
             for (OWLOntologyID key : struct.getOntologyKeysForSession(sessionId))
                 try {
-                    session.addOntology(
-                    // new GraphSource(key)
-                    Origin.create(key));
+                    session.addOntology(new StoredOntologySource(key));
                 } catch (MissingOntologyException ex) {
                     log.error(
                         "Could not find an ontology with public key {} to be managed by session \"{}\". Proceeding to next ontology.",

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/ontologies/meta.owl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/ontologies/meta.owl?rev=1371761&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/ontologies/meta.owl (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/ontologies/meta.owl Fri Aug 10 16:29:22 2012
@@ -0,0 +1,487 @@
+#  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.
+  
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+@prefix owl: <http://www.w3.org/2002/07/owl#> .
+@prefix : <http://stanbol.apache.org/ontology/meta/ontonet#> .
+@prefix xml: <http://www.w3.org/XML/1998/namespace> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@base <http://stanbol.apache.org/ontology/meta/ontonet> .
+
+<http://stanbol.apache.org/ontology/meta/ontonet> rdf:type owl:Ontology ;
+                                                  
+                                                  owl:versionIRI <http://svn.apache.org/repos/asf/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/ontologies/meta.owl> .
+
+
+#################################################################
+#
+#    Annotation properties
+#
+#################################################################
+
+
+
+
+#################################################################
+#
+#    Datatypes
+#
+#################################################################
+
+
+
+
+#################################################################
+#
+#    Object Properties
+#
+#################################################################
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasAppended
+
+:hasAppended rdf:type owl:ObjectProperty ;
+             
+             rdfs:label "hasAppended"@en ;
+             
+             rdfs:range :Scope ;
+             
+             rdfs:domain :Session ;
+             
+             owl:inverseOf :isAppendedTo .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasCoreSpace
+
+:hasCoreSpace rdf:type owl:FunctionalProperty ,
+                       owl:InverseFunctionalProperty ,
+                       owl:ObjectProperty ;
+              
+              rdfs:label "hasCoreSpace"@en ;
+              
+              rdfs:domain :Scope ;
+              
+              rdfs:range :Space ;
+              
+              owl:propertyDisjointWith :hasCustomSpace ;
+              
+              rdfs:subPropertyOf :hasSpace ;
+              
+              owl:inverseOf :isCoreSpaceOf .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasCustomSpace
+
+:hasCustomSpace rdf:type owl:FunctionalProperty ,
+                         owl:InverseFunctionalProperty ,
+                         owl:ObjectProperty ;
+                
+                rdfs:label "hasCustomSpace"@en ;
+                
+                rdfs:domain :Scope ;
+                
+                rdfs:range :Space ;
+                
+                rdfs:subPropertyOf :hasSpace ;
+                
+                owl:inverseOf :isCustomSpaceOf .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasSpace
+
+:hasSpace rdf:type owl:InverseFunctionalProperty ,
+                   owl:ObjectProperty ;
+          
+          rdfs:label "hasSpace"@en ;
+          
+          rdfs:domain :Scope ;
+          
+          rdfs:range :Space .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasStatus
+
+:hasStatus rdf:type owl:ObjectProperty ;
+           
+           rdfs:label "hasStatus"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isAppendedTo
+
+:isAppendedTo rdf:type owl:ObjectProperty ;
+              
+              rdfs:label "isAppendedTo"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isCoreSpaceOf
+
+:isCoreSpaceOf rdf:type owl:ObjectProperty ;
+               
+               rdfs:label "isCoreSpaceOf"@en ;
+               
+               owl:propertyDisjointWith :isCustomSpaceOf ;
+               
+               rdfs:subPropertyOf :isSpaceOf .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isCustomSpaceOf
+
+:isCustomSpaceOf rdf:type owl:ObjectProperty ;
+                 
+                 rdfs:label "isCustomSpaceOf"@en ;
+                 
+                 rdfs:subPropertyOf :isSpaceOf .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isManagedBy
+
+:isManagedBy rdf:type owl:ObjectProperty ;
+             
+             rdfs:label "isManagedBy"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isManagedByCore
+
+:isManagedByCore rdf:type owl:ObjectProperty ;
+                 
+                 rdfs:label "isManagedByCore"@en ;
+                 
+                 rdfs:subPropertyOf :isManagedBy ;
+                 
+                 owl:propertyDisjointWith :isManagedByCustom .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isManagedByCustom
+
+:isManagedByCustom rdf:type owl:ObjectProperty ;
+                   
+                   rdfs:label "isManagedByCustom"@en ;
+                   
+                   rdfs:subPropertyOf :isManagedBy .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#isSpaceOf
+
+:isSpaceOf rdf:type owl:ObjectProperty ;
+           
+           rdfs:label "isSpaceOf"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#manages
+
+:manages rdf:type owl:ObjectProperty ;
+         
+         rdfs:label "manages"@en ;
+         
+         rdfs:range :Entry ;
+         
+         rdfs:domain :OntologyCollector ;
+         
+         owl:inverseOf :isManagedBy .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#managesInCore
+
+:managesInCore rdf:type owl:ObjectProperty ;
+               
+               rdfs:label "managesInCore"@en ;
+               
+               rdfs:range :Entry ;
+               
+               rdfs:domain :Scope ;
+               
+               owl:inverseOf :isManagedByCore ;
+               
+               rdfs:subPropertyOf :manages ;
+               
+               owl:propertyDisjointWith :managesInCustom .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#managesInCustom
+
+:managesInCustom rdf:type owl:ObjectProperty ;
+                 
+                 rdfs:label "managesInCustom"@en ;
+                 
+                 rdfs:range :Entry ;
+                 
+                 rdfs:domain :Scope ;
+                 
+                 owl:inverseOf :isManagedByCustom ;
+                 
+                 rdfs:subPropertyOf :manages .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#mapsToGraph
+
+:mapsToGraph rdf:type owl:FunctionalProperty ,
+                      owl:ObjectProperty ;
+             
+             rdfs:label "mapsToGraph"@en ;
+             
+             rdfs:domain :Entry ;
+             
+             rdfs:range :Graph .
+
+
+
+
+
+#################################################################
+#
+#    Data properties
+#
+#################################################################
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasOntologyIRI
+
+:hasOntologyIRI rdf:type owl:DatatypeProperty ;
+                
+                rdfs:label "hasOntologyIRI"@en ;
+                
+                rdfs:domain :Entry ;
+                
+                rdfs:range xsd:anyURI .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasSizeInAxioms
+
+:hasSizeInAxioms rdf:type owl:DatatypeProperty ,
+                          owl:FunctionalProperty ;
+                 
+                 rdfs:label "hasSizeInAxioms"@en ;
+                 
+                 rdfs:domain :Entry ;
+                 
+                 rdfs:range xsd:int .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasSizeInTriples
+
+:hasSizeInTriples rdf:type owl:DatatypeProperty ,
+                           owl:FunctionalProperty ;
+                  
+                  rdfs:label "hasSizeInTriples"@en ;
+                  
+                  rdfs:domain :Entry ;
+                  
+                  rdfs:range xsd:int .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#hasVersionIRI
+
+:hasVersionIRI rdf:type owl:DatatypeProperty ;
+               
+               rdfs:label "hasVersionIRI"@en ;
+               
+               rdfs:domain :Entry ;
+               
+               rdfs:range xsd:anyURI .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#retrievedFrom
+
+:retrievedFrom rdf:type owl:DatatypeProperty ;
+               
+               rdfs:label "retrievedFrom"@en ;
+               
+               rdfs:domain :Entry ;
+               
+               rdfs:range xsd:anyURI .
+
+
+
+
+
+#################################################################
+#
+#    Classes
+#
+#################################################################
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Entry
+
+:Entry rdf:type owl:Class ;
+       
+       rdfs:label "Entry"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Graph
+
+:Graph rdf:type owl:Class ;
+       
+       rdfs:label "Graph"@en ;
+       
+       rdfs:subClassOf owl:Thing .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#OntologyCollector
+
+:OntologyCollector rdf:type owl:Class ;
+                   
+                   rdfs:label "OntologyCollector"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Scope
+
+:Scope rdf:type owl:Class ;
+       
+       rdfs:label "Scope"@en ;
+       
+       rdfs:subClassOf :OntologyCollector .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Session
+
+:Session rdf:type owl:Class ;
+         
+         rdfs:label "Session"@en ;
+         
+         rdfs:subClassOf :OntologyCollector .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Space
+
+:Space rdf:type owl:Class ;
+       
+       rdfs:label "Space"@en ;
+       
+       rdfs:subClassOf :OntologyCollector .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Status
+
+:Status rdf:type owl:Class ;
+        
+        rdfs:label "Status"@en ;
+        
+        owl:equivalentClass [ rdf:type owl:Class ;
+                              owl:oneOf ( :Status.INACTIVE
+                                          :Status.ACTIVE
+                                          :Status.ZOMBIE
+                                        )
+                            ] .
+
+
+
+
+
+#################################################################
+#
+#    Individuals
+#
+#################################################################
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Status.ACTIVE
+
+:Status.ACTIVE rdf:type :Status ,
+                        owl:NamedIndividual ;
+               
+               rdfs:label "Status.ACTIVE"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Status.INACTIVE
+
+:Status.INACTIVE rdf:type :Status ,
+                          owl:NamedIndividual ;
+                 
+                 rdfs:label "Status.INACTIVE"@en .
+
+
+
+###  http://stanbol.apache.org/ontology/meta/ontonet#Status.ZOMBIE
+
+:Status.ZOMBIE rdf:type :Status ,
+                        owl:NamedIndividual ;
+               
+               rdfs:label "Status.ZOMBIE"@en .
+
+
+
+
+
+#################################################################
+#
+#    General axioms
+#
+#################################################################
+
+
+[ rdf:type owl:AllDifferent ;
+  owl:distinctMembers ( :Status.ACTIVE
+                        :Status.INACTIVE
+                        :Status.ZOMBIE
+                      )
+] .
+[ rdf:type owl:AllDisjointClasses ;
+  owl:members ( :Entry
+                :Graph
+                :OntologyCollector
+                :Status
+              )
+] .
+[ rdf:type owl:AllDisjointProperties ;
+  owl:members ( :hasAppended
+                :hasSpace
+                :hasStatus
+                :isAppendedTo
+                :isManagedBy
+                :isSpaceOf
+                :manages
+                :mapsToGraph
+              )
+] .
+[ rdf:type owl:AllDisjointClasses ;
+  owl:members ( :Scope
+                :Session
+                :Space
+              )
+] .
+
+
+
+
+###  Generated by the OWL API (version 3.2.3.1824) http://owlapi.sourceforge.net
+

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestOntologyNetworkPersistence.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestOntologyNetworkPersistence.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestOntologyNetworkPersistence.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestOntologyNetworkPersistence.java Fri Aug 10 16:29:22 2012
@@ -20,8 +20,8 @@ import static org.apache.stanbol.ontolog
 import static org.apache.stanbol.ontologymanager.ontonet.MockOsgiContext.parser;
 import static org.apache.stanbol.ontologymanager.ontonet.MockOsgiContext.resetManagers;
 import static org.apache.stanbol.ontologymanager.ontonet.MockOsgiContext.sessionManager;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_MANAGED_BY;
-import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MANAGES;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.IS_MANAGED_BY_URIREF;
+import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary.MANAGES_URIREF;
 import static org.apache.stanbol.ontologymanager.ontonet.api.Vocabulary._NS_STANBOL_INTERNAL;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -30,6 +30,7 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 
 import java.io.InputStream;
+import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
@@ -97,39 +98,35 @@ public class TestOntologyNetworkPersiste
          * characters_all, main, minor + mockfoaf (note: imports are available only because the xml:base is
          * set to be the same as the import target)
          */
-        assertEquals(total, ontologyProvider.getPublicKeys().size());
+        assertEquals(total, ontologyProvider.listOntologies().size());
 
         // Check that each imported ontology is stored
-        oAll = ontologyProvider.getStoredOntology(ontologyProvider.getKey(all), OWLOntology.class, false);
+        oAll = ontologyProvider.getStoredOntology(all, OWLOntology.class, false);
         OWLOntologyID id = oAll.getOntologyID();
         assertNotNull(id);
         assertEquals(all, id);
-        oMain = ontologyProvider.getStoredOntology(ontologyProvider.getKey(main), OWLOntology.class, false);
+        oMain = ontologyProvider.getStoredOntology(main, OWLOntology.class, false);
         id = oMain.getOntologyID();
         assertNotNull(id);
         assertEquals(main, id);
-        oMinor = ontologyProvider.getStoredOntology(ontologyProvider.getKey(minor), OWLOntology.class, false);
+        oMinor = ontologyProvider.getStoredOntology(minor, OWLOntology.class, false);
         id = oMinor.getOntologyID();
         assertNotNull(id);
         assertEquals(minor, id);
-        oFoaf = ontologyProvider.getStoredOntology(ontologyProvider.getKey(foaf), OWLOntology.class, false);
+        oFoaf = ontologyProvider.getStoredOntology(foaf, OWLOntology.class, false);
         id = oFoaf.getOntologyID();
         assertNotNull(id);
         assertEquals(foaf, id);
 
         log.info("Stanbol going down...");
         resetOntologyProvider(); // but keep the TcProvider
-        assertEquals(total, ontologyProvider.getPublicKeys().size());
+        assertEquals(total, ontologyProvider.listOntologies().size());
 
         // The OWL API implements OWLOntology#equals()
-        assertEquals(oAll,
-            ontologyProvider.getStoredOntology(ontologyProvider.getKey(all), OWLOntology.class, false));
-        assertEquals(oMain,
-            ontologyProvider.getStoredOntology(ontologyProvider.getKey(main), OWLOntology.class, false));
-        assertEquals(oMinor,
-            ontologyProvider.getStoredOntology(ontologyProvider.getKey(minor), OWLOntology.class, false));
-        assertEquals(oFoaf,
-            ontologyProvider.getStoredOntology(ontologyProvider.getKey(foaf), OWLOntology.class, false));
+        assertEquals(oAll, ontologyProvider.getStoredOntology(all, OWLOntology.class, false));
+        assertEquals(oMain, ontologyProvider.getStoredOntology(main, OWLOntology.class, false));
+        assertEquals(oMinor, ontologyProvider.getStoredOntology(minor, OWLOntology.class, false));
+        assertEquals(oFoaf, ontologyProvider.getStoredOntology(foaf, OWLOntology.class, false));
     }
 
     @Test
@@ -146,28 +143,28 @@ public class TestOntologyNetworkPersiste
         assertFalse(key.isAnonymous());
 
         // Retrieve the stored fake FOAF
-        assertEquals(1, ontologyProvider.getPublicKeys().size());
+        assertEquals(1, ontologyProvider.listOntologies().size());
         o1 = ontologyProvider.getStoredOntology(key, OWLOntology.class, false);
         OWLOntologyID id = o1.getOntologyID();
         assertNotNull(id);
         assertEquals(foaf, id);
 
         // Check there is a storage key for the (real) ID of the FOAF ontology
-//        key = ontologyProvider.getKey(foaf);
-//        assertNotNull(key);
-//        assertFalse(key.isAnonymous());
+        // key = ontologyProvider.getKey(foaf);
+        // assertNotNull(key);
+        // assertFalse(key.isAnonymous());
         assertTrue(ontologyProvider.hasOntology(foaf));
 
         log.info("Stanbol going down...");
         resetOntologyProvider(); // but keep the TcProvider
-        assertEquals(1, ontologyProvider.getPublicKeys().size());
+        assertEquals(1, ontologyProvider.listOntologies().size());
 
         // Check again for the FOAF key
-//        key = ontologyProvider.getKey(foaf);
-//        assertNotNull(key);
-//        assertFalse(key.isAnonymous());
+        // key = ontologyProvider.getKey(foaf);
+        // assertNotNull(key);
+        // assertFalse(key.isAnonymous());
         assertTrue(ontologyProvider.hasOntology(foaf));
-        
+
         // The OWL API implements OWLOntology#equals()
         assertEquals(o1, ontologyProvider.getStoredOntology(key, OWLOntology.class, false));
     }
@@ -185,14 +182,15 @@ public class TestOntologyNetworkPersiste
     }
 
     @Test
-    public void preservesManagedOntologies() throws Exception {
+    public void scopePreservesManagedOntologies() throws Exception {
         String id = "preserve";
         OntologyScope scope = onManager.createOntologyScope(id, new GraphContentInputSource(getClass()
                 .getResourceAsStream("/ontologies/mockfoaf.rdf")));
         scope.getCustomSpace().addOntology(
             new GraphContentInputSource(getClass().getResourceAsStream(
                 "/ontologies/nonexistentcharacters.owl")));
-
+        Collection<OWLOntologyID> cores = scope.getCoreSpace().listManagedOntologies();
+        Collection<OWLOntologyID> customs = scope.getCustomSpace().listManagedOntologies();
         // Simulate Stanbol going down.
         log.info("Stanbol going down...");
         resetOntologyProvider(); // but keep the TcProvider
@@ -200,7 +198,38 @@ public class TestOntologyNetworkPersiste
 
         OntologyScope sc = onManager.getScope(id);
         assertNotNull(sc);
-        // assertEquals(scope, sc); XXX should scopes be equal on ID + content?
+        assertEquals(cores, sc.getCoreSpace().listManagedOntologies());
+        assertEquals(customs, sc.getCustomSpace().listManagedOntologies());
+        assertEquals(scope, sc); // XXX Remember that only weak equality is implemented.
+    }
+
+    @Test
+    public void sessionPreservesManagedOntologies() throws Exception {
+        String id = "12345"; // The kind of thing an idiot would have on his luggage.
+        Session session = sessionManager.createSession(id);
+        // Anonymous ontologies must preserve their public keys!
+        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
+            "/ontologies/nameless_ontology.owl")));
+        // Same for named ontologies...
+        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
+            "/ontologies/nonexistentcharacters.owl")));
+        // ... and versioned ontologies too.
+        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
+            "/ontologies/versiontest_v1.owl")));
+        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
+            "/ontologies/versiontest_v2.owl")));
+        Collection<OWLOntologyID> managed = session.listManagedOntologies();
+        assertEquals(4, managed.size());
+        
+        // Simulate Stanbol going down.
+        log.info("Stanbol going down...");
+        resetOntologyProvider(); // but keep the TcProvider
+        resetManagers();
+
+        Session ses = sessionManager.getSession(id);
+        assertNotNull(ses);
+        assertEquals(managed, ses.listManagedOntologies());
+        assertEquals(session, ses); // XXX Remember that only weak equality is implemented.
     }
 
     /*
@@ -266,9 +295,9 @@ public class TestOntologyNetworkPersiste
                                       + scope.getCoreSpace().getID());
         UriRef test1id = new UriRef("http://stanbol.apache.org/ontologies/test1.owl"); // Has no versionIRI
         // Be strict: the whole property pair must be there.
-        UriRef predicate = MANAGES;
+        UriRef predicate = MANAGES_URIREF;
         assertTrue(meta.contains(new TripleImpl(collector, predicate, test1id)));
-        predicate = IS_MANAGED_BY;
+        predicate = IS_MANAGED_BY_URIREF;
         assertTrue(meta.contains(new TripleImpl(test1id, predicate, collector)));
 
         scope.tearDown(); // To modify the core space.
@@ -276,9 +305,9 @@ public class TestOntologyNetworkPersiste
         scope.getCoreSpace().addOntology(
             new GraphContentInputSource(getClass().getResourceAsStream("/ontologies/minorcharacters.owl")));
         UriRef minorId = new UriRef("http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl");
-        predicate = MANAGES;
+        predicate = MANAGES_URIREF;
         assertTrue(meta.contains(new TripleImpl(collector, predicate, minorId)));
-        predicate = IS_MANAGED_BY;
+        predicate = IS_MANAGED_BY_URIREF;
         assertTrue(meta.contains(new TripleImpl(minorId, predicate, collector)));
 
         scope.getCustomSpace().addOntology(

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestClerezzaInputSources.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestClerezzaInputSources.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestClerezzaInputSources.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestClerezzaInputSources.java Fri Aug 10 16:29:22 2012
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertNot
 
 import java.io.InputStream;
 import java.util.Hashtable;
-import java.util.Set;
 
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
@@ -116,11 +115,11 @@ public class TestClerezzaInputSources {
         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);
+        // 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);
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOWLAPIInputSources.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOWLAPIInputSources.java?rev=1371761&r1=1371760&r2=1371761&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOWLAPIInputSources.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOWLAPIInputSources.java Fri Aug 10 16:29:22 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.io;
 
-import static org.apache.stanbol.ontologymanager.ontonet.MockOsgiContext.ontologyProvider;
 import static org.apache.stanbol.ontologymanager.ontonet.MockOsgiContext.reset;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -27,18 +26,13 @@ import java.io.File;
 import java.io.FileWriter;
 import java.net.URI;
 import java.net.URL;
-import java.util.Dictionary;
-import java.util.Hashtable;
 import java.util.Set;
 
 import org.apache.stanbol.commons.owl.OWLOntologyManagerFactory;
 import org.apache.stanbol.ontologymanager.ontonet.Constants;
-import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.ParentPathInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologyIRISource;
-import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
-import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
 import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -58,12 +52,8 @@ public class TestOWLAPIInputSources {
 
     private static OWLDataFactory df;
 
-    private static ONManager onm;
-
     @BeforeClass
     public static void setUp() {
-        Dictionary<String,Object> onmconf = new Hashtable<String,Object>();
-        onm = new ONManagerImpl(ontologyProvider, new OfflineConfigurationImpl(onmconf), null, onmconf);
         df = OWLManager.getOWLDataFactory();
     }
 
@@ -119,10 +109,10 @@ public class TestOWLAPIInputSources {
         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());
+        // // 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));