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 2011/09/29 20:10:58 UTC
svn commit: r1177383 [2/3] - in /incubator/stanbol/trunk:
enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/
ontologymanager/ontonet/
ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/ap...
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java Thu Sep 29 18:10:56 2011
@@ -18,15 +18,12 @@ package org.apache.stanbol.ontologymanag
import java.util.Random;
-import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologySource;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpace;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SessionOntologySpace;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SpaceType;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
-import org.apache.stanbol.ontologymanager.ontonet.impl.util.StringUtils;
import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;
/**
@@ -36,10 +33,17 @@ public class SessionOntologySpaceImpl ex
public static final String SUFFIX = SpaceType.SESSION.getIRISuffix();
- public SessionOntologySpaceImpl(IRI scopeID, ClerezzaOntologyStorage store) {
+ private static String buildId(String scopeID) {
+ return (scopeID!=null?scopeID:"") + "/" + SpaceType.SESSION.getIRISuffix() + "-" + new Random().nextLong();
+ }
+
+ public SessionOntologySpaceImpl(String scopeID, IRI namespace, ClerezzaOntologyStorage store) {
// FIXME : sync session id with session space ID
- super(IRI.create(StringUtils.stripIRITerminator(scopeID) + "/" + SpaceType.SESSION.getIRISuffix()
- + "-" + new Random().nextLong()), SpaceType.SESSION, store/* , scopeID */);
+ super(buildId(scopeID), namespace
+ /*
+ * IRI.create(StringUtils.stripIRITerminator(scopeID) + "/" + SpaceType.SESSION.getIRISuffix() + "-" +
+ * new Random().nextLong())
+ */, SpaceType.SESSION, store/* , scopeID */);
// IRI iri = IRI.create(StringUtils.stripIRITerminator(getID()) + "/root.owl");
// try {
@@ -53,13 +57,17 @@ public class SessionOntologySpaceImpl ex
// }
}
- public SessionOntologySpaceImpl(IRI scopeID,
+ public SessionOntologySpaceImpl(String scopeID,
+ IRI namespace,
ClerezzaOntologyStorage store,
OWLOntologyManager ontologyManager) {
// FIXME : sync session id with session space ID
- super(IRI.create(StringUtils.stripIRITerminator(scopeID) + "/" + SpaceType.SESSION.getIRISuffix()
- + "-" + new Random().nextLong()), SpaceType.SESSION, store, /* scopeID, */
+ super(buildId(scopeID), namespace
+ /*
+ * IRI.create(StringUtils.stripIRITerminator(scopeID) + "/" + SpaceType.SESSION.getIRISuffix() + "-" +
+ * new Random().nextLong())
+ */, SpaceType.SESSION, store, /* scopeID, */
ontologyManager);
// Logger log = LoggerFactory.getLogger(getClass());
@@ -78,19 +86,19 @@ public class SessionOntologySpaceImpl ex
@Override
public void attachSpace(OntologySpace space, boolean skipRoot) throws UnmodifiableOntologySpaceException {
// FIXME re-implement!
-// if (!(space instanceof SessionOntologySpace)) {
-// OWLOntology o = space.getTopOntology();
-// // This does the append thingy
-// log.debug("Attaching " + o + " TO " + getTopOntology() + " ...");
-// try {
-// // It is in fact the addition of the core space top ontology to the
-// // custom space, with import statements and all.
-// addOntology(new RootOntologySource(o, null));
-// // log.debug("ok");
-// } catch (Exception ex) {
-// log.error("FAILED", ex);
-// }
-// }
+ // if (!(space instanceof SessionOntologySpace)) {
+ // OWLOntology o = space.getTopOntology();
+ // // This does the append thingy
+ // log.debug("Attaching " + o + " TO " + getTopOntology() + " ...");
+ // try {
+ // // It is in fact the addition of the core space top ontology to the
+ // // custom space, with import statements and all.
+ // addOntology(new RootOntologySource(o, null));
+ // // log.debug("ok");
+ // } catch (Exception ex) {
+ // log.error("FAILED", ex);
+ // }
+ // }
}
@Override
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=1177383&r1=1177382&r2=1177383&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 Thu Sep 29 18:10:56 2011
@@ -70,8 +70,8 @@ public class ScopeSetRenderer {
additions.add(new AddImport(ont, __factory
.getOWLImportsDeclaration(IRI.create("http://www.ontologydesignpatterns.org/schemas/meta.owl"))));
for (OntologyScope scope : scopes) {
- OWLNamedIndividual iScope = __factory.getOWLNamedIndividual(scope
- .getID());
+ OWLNamedIndividual iScope = __factory.getOWLNamedIndividual(IRI.create(scope.getNamespace()+scope
+ .getID()));
OWLAxiom ax = __factory.getOWLClassAssertionAxiom(cScope, iScope);
additions.add(new AddAxiom(ont, ax));
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/ScopeSessionSynchronizer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/ScopeSessionSynchronizer.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/ScopeSessionSynchronizer.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/ScopeSessionSynchronizer.java Thu Sep 29 18:10:56 2011
@@ -40,7 +40,8 @@ public class ScopeSessionSynchronizer im
OntologySpaceFactory factory = manager.getOntologySpaceFactory();
for (OntologyScope scope : manager.getScopeRegistry().getActiveScopes()) {
try {
- scope.addSessionSpace(factory.createSessionOntologySpace(scope.getID()), sessionId);
+ String scopeId = scope.getID().toString().substring(scope.getID().toString().lastIndexOf("/")+1);
+ scope.addSessionSpace(factory.createSessionOntologySpace(scopeId), sessionId);
} catch (UnmodifiableOntologySpaceException e) {
LoggerFactory.getLogger(getClass()).warn("Tried to add session to unmodifiable space ");
continue;
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=1177383&r1=1177382&r2=1177383&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 Thu Sep 29 18:10:56 2011
@@ -107,7 +107,7 @@ public class SessionManagerImpl implemen
try {
session = createSession(idgen.createSessionID(exclude));
} catch (DuplicateSessionIDException e) {
- exclude.add(e.getDulicateID());
+ exclude.add(IRI.create(e.getDulicateID()));
continue;
}
return session;
@@ -121,7 +121,7 @@ public class SessionManagerImpl implemen
*/
@Override
public synchronized Session createSession(IRI sessionID) throws DuplicateSessionIDException {
- if (sessionsByID.containsKey(sessionID)) throw new DuplicateSessionIDException(sessionID);
+ if (sessionsByID.containsKey(sessionID)) throw new DuplicateSessionIDException(sessionID.toString());
Session session = new SessionImpl(sessionID);
addSession(session);
fireSessionCreated(session);
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/util/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/util/StringUtils.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/util/StringUtils.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/util/StringUtils.java Thu Sep 29 18:10:56 2011
@@ -35,5 +35,11 @@ public class StringUtils {
else
return iri;
}
+
+ public static String stripNamespace(String fullIri, String namespace) {
+ if (fullIri.startsWith(namespace))
+ return fullIri.substring(namespace.length()-1);
+ else return fullIri;
+ }
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java Thu Sep 29 18:10:56 2011
@@ -55,6 +55,8 @@ public class Locations {
*/
public static final IRI CHAR_MAIN = IRI.create(__STANBOL_ONT_NAMESPACE + "pcomics/maincharacters.owl");
+ public static final IRI CHAR_MINOR = IRI.create(__STANBOL_ONT_NAMESPACE + "pcomics/minorcharacters.owl");
+
/**
* Identifier of test ontology library 1.
*/
Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/MockOsgiContext.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/MockOsgiContext.java?rev=1177383&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/MockOsgiContext.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/MockOsgiContext.java Thu Sep 29 18:10:56 2011
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.simple.storage.SimpleTcProvider;
+
+public class MockOsgiContext {
+
+ public static Parser parser;
+
+ public static TcManager tcManager;
+
+ static {
+ reset();
+ }
+
+ public static void reset() {
+ tcManager = new TcManager();
+ tcManager.addWeightedTcProvider(new SimpleTcProvider());
+ }
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOntologyInputSources.java Thu Sep 29 18:10:56 2011
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.ontologymanager.ontonet.io;
import static org.junit.Assert.*;
Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestStorage.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestStorage.java?rev=1177383&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestStorage.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestStorage.java Thu Sep 29 18:10:56 2011
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.io;
+
+import static org.junit.Assert.*;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.stanbol.ontologymanager.ontonet.Constants;
+import org.apache.stanbol.ontologymanager.ontonet.MockOsgiContext;
+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.RootOntologyIRISource;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope;
+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;
+import org.semanticweb.owlapi.model.IRI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestStorage {
+
+ private static ONManager onm;
+
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ private String scopeId = "StorageTest";
+
+ @BeforeClass
+ public static void setup() {
+ // Empty configurations are fine, but this time we provide a Clerezza context.
+ onm = new ONManagerImpl(MockOsgiContext.tcManager, MockOsgiContext.tcManager.getProviderList()
+ .first(), new OfflineConfigurationImpl(new Hashtable<String,Object>()),
+ new Hashtable<String,Object>());
+ }
+
+ @Test
+ public void storageOnScopeCreation() throws Exception {
+ assertTrue(onm.getOntologyStore().listGraphs().isEmpty());
+ OntologyInputSource ois = new RootOntologyIRISource(IRI.create(getClass().getResource(
+ "/ontologies/minorcharacters.owl")));
+
+ OntologyScope sc = onm.getOntologyScopeFactory().createOntologyScope(scopeId, ois);
+
+ Set<Triple> triples = new HashSet<Triple>();
+
+ for (IRI iri : onm.getOntologyStore().listGraphs()) {
+ log.info("{}", iri.toString());
+ UriRef entity = new UriRef(Constants.PEANUTS_MINOR_BASE + "#" + Constants.truffles);
+ Graph ctx = new GraphNode(entity, onm.getOntologyStore().getGraph(
+ new UriRef(iri.toString().substring(1, iri.toString().length() - 1)))).getNodeContext();
+ Iterator<Triple> it = ctx.iterator();
+ while (it.hasNext())
+ triples.add(it.next());
+ }
+
+ assertFalse(onm.getOntologyStore().listGraphs().isEmpty());
+ assertEquals(3, triples.size());
+ }
+
+ @After
+ public void reset() {
+ MockOsgiContext.reset();
+ }
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java Thu Sep 29 18:10:56 2011
@@ -1,40 +1,39 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.ontologymanager.ontonet.ontology;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
+import java.util.Dictionary;
import java.util.Hashtable;
import org.apache.stanbol.ontologymanager.ontonet.Constants;
import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.BlankOntologySource;
import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologySource;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScopeFactory;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.CoreOntologySpaceImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.CustomOntologySpaceImpl;
-import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OWLOntologyManagerFactoryImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OntologyScopeFactoryImpl;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -46,10 +45,9 @@ import org.semanticweb.owlapi.model.OWLO
public class TestOntologyScope {
public static IRI baseIri = IRI.create(Constants.PEANUTS_MAIN_BASE), baseIri2 = IRI
- .create(Constants.PEANUTS_MINOR_BASE), scopeIriBlank = IRI
- .create("http://kres.iks-project.eu/scope/WackyRaces"), scopeIri1 = IRI
- .create("http://kres.iks-project.eu/scope/Peanuts"), scopeIri2 = IRI
- .create("http://kres.iks-project.eu/scope/CalvinAndHobbes");
+ .create(Constants.PEANUTS_MINOR_BASE);
+
+ public static String scopeIdBlank = "WackyRaces", scopeId1 = "Peanuts", scopeId2 = "CalvinAndHobbes";
/**
* An ontology scope that initially contains no ontologies, and is rebuilt from scratch before each test
@@ -65,8 +63,11 @@ public class TestOntologyScope {
@BeforeClass
public static void setup() {
- // An ONManagerImpl with no store and default settings
- onm = new ONManagerImpl(null, null, new Hashtable<String,Object>());
+ // An ONManagerImpl with no store and a set namespace.
+ Dictionary<String,Object> onmconf = new Hashtable<String,Object>();
+ onmconf.put(ONManager.ONTOLOGY_NETWORK_NS, "http://stanbol.apache.org/scope/");
+ // The same hashtable can be recycled for the offline configuration.
+ onm = new ONManagerImpl(null, null, new OfflineConfigurationImpl(onmconf), onmconf);
factory = onm.getOntologyScopeFactory();
if (factory == null) fail("Could not instantiate ontology space factory");
OWLOntologyManager mgr = onm.getOntologyManagerFactory().createOntologyManager(true);
@@ -79,8 +80,8 @@ public class TestOntologyScope {
}
@Before
- public void cleaup() throws DuplicateIDException {
- if (factory != null) blankScope = factory.createOntologyScope(scopeIriBlank, null);
+ public void cleanup() throws DuplicateIDException {
+ if (factory != null) blankScope = factory.createOntologyScope(scopeIdBlank, null);
}
/**
@@ -88,20 +89,88 @@ public class TestOntologyScope {
* spaces.
*/
@Test
- public void testIdentifiers() {
- OntologyScope scope = null;
+ public void testIdentifiers() throws Exception {
+
+ OntologyScope shouldBeNull = null, shouldBeNotNull = null;
+
+ /* First test scope identifiers. */
+
+ // Null identifier (invalid)
try {
- scope = factory.createOntologyScope(scopeIri1, src1, src2);
- scope.setUp();
+ shouldBeNull = factory.createOntologyScope(null, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite null scope identifier.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Slash in identifier (invalid)
+ try {
+ shouldBeNull = factory.createOntologyScope("a0/b1", new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite slash in scope identifier.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ /* Now test namespaces. */
+
+ // Null namespace (invalid).
+ factory.setNamespace(null);
+ try {
+ shouldBeNull = factory.createOntologyScope(scopeIdBlank, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite null OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace with query (invalid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology/?query=true"));
+ try {
+ shouldBeNull = factory.createOntologyScope(scopeIdBlank, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite query in OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace with fragment (invalid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology#fragment"));
+ try {
+ shouldBeNull = factory.createOntologyScope(scopeIdBlank, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace ending with hash (invalid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology#"));
+ try {
+ shouldBeNull = factory.createOntologyScope(scopeIdBlank, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace ending with slash (valid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
+ shouldBeNotNull = factory.createOntologyScope(scopeIdBlank, new BlankOntologySource());
+ assertNotNull(shouldBeNotNull);
+
+ shouldBeNotNull = null;
+
+ // Namespace ending with neither (valid, should automatically add slash).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology"));
+ shouldBeNotNull = factory.createOntologyScope(scopeIdBlank, new BlankOntologySource());
+ assertNotNull(shouldBeNotNull);
+ assertTrue(shouldBeNotNull.getNamespace().toString().endsWith("/"));
+
+ // Now set again the correct namespace.
+ factory.setNamespace(IRI.create(onm.getOntologyNetworkNamespace()));
+ shouldBeNotNull = null;
+ try {
+ shouldBeNotNull = factory.createOntologyScope(scopeId1, src1, src2);
+ shouldBeNotNull.setUp();
} catch (DuplicateIDException e) {
fail("Unexpected DuplicateIDException caught when creating scope "
+ "with non-null parameters in a non-registered environment.");
}
- boolean condition = scope.getID().equals(scopeIri1);
- condition &= scope.getCoreSpace().getID()
- .equals(IRI.create(scopeIri1 + "/" + CoreOntologySpaceImpl.SUFFIX));
- condition &= scope.getCustomSpace().getID()
- .equals(IRI.create(scopeIri1 + "/" + CustomOntologySpaceImpl.SUFFIX));
+ boolean condition = shouldBeNotNull.getID().equals(scopeId1);
+ condition &= shouldBeNotNull.getCoreSpace().getID()
+ .equals(scopeId1 + "/" + CoreOntologySpaceImpl.SUFFIX);
+ condition &= shouldBeNotNull.getCustomSpace().getID()
+ .equals(scopeId1 + "/" + CustomOntologySpaceImpl.SUFFIX);
assertTrue(condition);
}
@@ -116,7 +185,7 @@ public class TestOntologyScope {
} catch (DuplicateIDException e) {
fail("Unexpected DuplicateIDException caught while testing scope creation"
+ " with null parameters.");
- } catch (NullPointerException ex) {
+ } catch (IllegalArgumentException ex) {
// Expected behaviour.
}
assertNull(scope);
@@ -130,7 +199,7 @@ public class TestOntologyScope {
public void testScopeSetup() {
OntologyScope scope = null;
try {
- scope = factory.createOntologyScope(scopeIri1, src1, src2);
+ scope = factory.createOntologyScope(scopeId1, src1, src2);
scope.setUp();
} catch (DuplicateIDException e) {
fail("Unexpected DuplicateIDException was caught while testing scope " + e.getDulicateID());
@@ -146,7 +215,7 @@ public class TestOntologyScope {
public void testScopeSetupNoCustom() {
OntologyScope scope = null;
try {
- scope = factory.createOntologyScope(scopeIri2, src1);
+ scope = factory.createOntologyScope(scopeId2, src1);
scope.setUp();
} catch (DuplicateIDException e) {
fail("Duplicate ID exception caught for scope iri " + src1);
@@ -158,11 +227,12 @@ public class TestOntologyScope {
@Test
public void testScopesRendering() {
ScopeRegistry reg = onm.getScopeRegistry();
- OntologyScopeFactoryImpl scf = new OntologyScopeFactoryImpl(reg, onm.getOntologySpaceFactory());
+ OntologyScopeFactoryImpl scf = new OntologyScopeFactoryImpl(reg, onm.getOntologyScopeFactory()
+ .getNamespace(), onm.getOntologySpaceFactory());
OntologyScope scope = null, scope2 = null;
try {
- scope = scf.createOntologyScope(scopeIri1, src1, src2);
- scope2 = scf.createOntologyScope(scopeIri2, src2);
+ scope = scf.createOntologyScope(scopeId1, src1, src2);
+ scope2 = scf.createOntologyScope(scopeId2, src2);
scope.setUp();
reg.registerScope(scope);
scope2.setUp();
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java Thu Sep 29 18:10:56 2011
@@ -26,13 +26,16 @@ import java.util.Hashtable;
import org.apache.stanbol.ontologymanager.ontonet.Constants;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.BlankOntologySource;
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.RootOntologySource;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.CoreOntologySpace;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.CustomOntologySpace;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpace;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceFactory;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SessionOntologySpace;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SpaceType;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
@@ -52,8 +55,9 @@ import org.semanticweb.owlapi.model.OWLO
public class TestOntologySpaces {
public static IRI baseIri = IRI.create(Constants.PEANUTS_MAIN_BASE), baseIri2 = IRI
- .create(Constants.PEANUTS_MINOR_BASE), scopeIri = IRI
- .create("http://stanbol.apache.org/scope/Comics");
+ .create(Constants.PEANUTS_MINOR_BASE);
+
+ String scopeId = "Comics";
private static OWLAxiom linusIsHuman = null;
@@ -63,7 +67,7 @@ public class TestOntologySpaces {
private static OntologyInputSource inMemorySrc, minorSrc, dropSrc, nonexSrc;
- private static OntologySpaceFactory spaceFactory;
+ private static OntologySpaceFactory factory;
private static OfflineConfiguration offline;
@@ -83,8 +87,8 @@ public class TestOntologySpaces {
// An ONManagerImpl with no store and default settings
onm = new ONManagerImpl(null, null, offline, new Hashtable<String,Object>());
- spaceFactory = onm.getOntologySpaceFactory();
- if (spaceFactory == null) fail("Could not instantiate ontology space factory");
+ factory = onm.getOntologySpaceFactory();
+ if (factory == null) fail("Could not instantiate ontology space factory");
OWLOntologyManager mgr = OWLOntologyManagerFactory.createOWLOntologyManager(offline
.getOntologySourceLocations().toArray(new IRI[0]));
@@ -107,12 +111,87 @@ public class TestOntologySpaces {
}
+ /**
+ * Checks whether attempting to create ontology spaces with invalid identifiers or namespaces results in
+ * the appropriate exceptions being thrown.
+ *
+ * @throws Exception
+ * if an unexpected error occurs.
+ */
+ @Test
+ public void testIdentifiers() throws Exception {
+ OntologySpace shouldBeNull = null, shouldBeNotNull = null;
+
+ /* First test space identifiers. */
+
+ // Null identifier (invalid).
+ try {
+ shouldBeNull = factory.createOntologySpace(null, SpaceType.CORE, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite null scope identifier.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // More than one slash in identifier (invalid).
+ try {
+ shouldBeNull = factory.createOntologySpace("Sc0/p3", SpaceType.CORE, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite null scope identifier.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ /* Now test namespaces. */
+
+ // Null namespace (invalid).
+ factory.setNamespace(null);
+ try {
+ shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite null OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace with query (invalid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology/?query=true"));
+ try {
+ shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite query in OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace with fragment (invalid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology#fragment"));
+ try {
+ shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace ending with hash (invalid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology#"));
+ try {
+ shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
+ fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
+ } catch (IllegalArgumentException ex) {}
+ assertNull(shouldBeNull);
+
+ // Namespace ending with neither (valid, should automatically add slash).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology"));
+ shouldBeNotNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
+ assertNotNull(shouldBeNotNull);
+ assertTrue(shouldBeNotNull.getNamespace().toString().endsWith("/"));
+
+ shouldBeNotNull = null;
+
+ // Namespace ending with slash (valid).
+ factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
+ shouldBeNotNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
+ assertNotNull(shouldBeNotNull);
+ }
+
@Test
public void testAddOntology() throws Exception {
CustomOntologySpace space = null;
IRI logicalId = nonexSrc.getRootOntology().getOntologyID().getOntologyIRI();
- space = spaceFactory.createCustomOntologySpace(scopeIri, dropSrc);
+ space = factory.createCustomOntologySpace(scopeId, dropSrc);
space.addOntology(minorSrc);
space.addOntology(nonexSrc);
@@ -123,7 +202,7 @@ public class TestOntologySpaces {
@Test
public void testCoreLock() throws Exception {
- CoreOntologySpace space = spaceFactory.createCoreOntologySpace(scopeIri, inMemorySrc);
+ CoreOntologySpace space = factory.createCoreOntologySpace(scopeId, inMemorySrc);
space.setUp();
try {
space.addOntology(minorSrc);
@@ -135,14 +214,14 @@ public class TestOntologySpaces {
@Test
public void testCreateSpace() throws Exception {
- CustomOntologySpace space = spaceFactory.createCustomOntologySpace(scopeIri, dropSrc);
+ CustomOntologySpace space = factory.createCustomOntologySpace(scopeId, dropSrc);
IRI logicalId = dropSrc.getRootOntology().getOntologyID().getOntologyIRI();
assertTrue(space.containsOntology(logicalId));
}
@Test
public void testCustomLock() throws Exception {
- CustomOntologySpace space = spaceFactory.createCustomOntologySpace(scopeIri, inMemorySrc);
+ CustomOntologySpace space = factory.createCustomOntologySpace(scopeId, inMemorySrc);
space.setUp();
try {
space.addOntology(minorSrc);
@@ -155,7 +234,7 @@ public class TestOntologySpaces {
@Test
public void testRemoveCustomOntology() throws Exception {
CustomOntologySpace space = null;
- space = spaceFactory.createCustomOntologySpace(scopeIri, dropSrc);
+ space = factory.createCustomOntologySpace(scopeId, dropSrc);
IRI dropId = dropSrc.getRootOntology().getOntologyID().getOntologyIRI();
IRI nonexId = nonexSrc.getRootOntology().getOntologyID().getOntologyIRI();
@@ -174,7 +253,7 @@ public class TestOntologySpaces {
@Test
public void testSessionModification() throws Exception {
- SessionOntologySpace space = spaceFactory.createSessionOntologySpace(scopeIri);
+ SessionOntologySpace space = factory.createSessionOntologySpace(scopeId);
space.setUp();
try {
// First add an in-memory ontology with a few axioms.
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java Thu Sep 29 18:10:56 2011
@@ -1,19 +1,19 @@
/*
-* 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.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.ontologymanager.ontonet.session;
import static org.junit.Assert.*;
@@ -42,149 +42,140 @@ import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
-
public class TestSessions {
- public static IRI baseIri = IRI.create(Constants.PEANUTS_MAIN_BASE),
- baseIri2 = IRI.create(Constants.PEANUTS_MINOR_BASE),
- scopeIri1 = IRI.create("http://kres.iks-project.eu/scope/Ranma12"),
- scopeIri2 = IRI
- .create("http://kres.iks-project.eu/scope/HokutoNoKen"),
- scopeIri3 = IRI.create("http://kres.iks-project.eu/scope/Doraemon");
-
- private static OntologyScopeFactory scopeFactory = null;
-
- private static ScopeRegistry scopeRegistry = null;
-
- private static SessionManager sesmgr = null;
-
- private static OntologySpaceFactory spaceFactory = null;
-
- private static OntologyInputSource src1 = null, src2 = null;
-
- @BeforeClass
- public static void setup() {
- // An ONManagerImpl with no store and default settings
- ONManager onm = new ONManagerImpl(null,null, new Hashtable<String, Object>());
- sesmgr = onm.getSessionManager();
- scopeFactory = onm.getOntologyScopeFactory();
- spaceFactory = onm.getOntologySpaceFactory();
- scopeRegistry = onm.getScopeRegistry();
- if (spaceFactory == null)
- fail("Could not instantiate ontology space factory");
- if (scopeFactory == null)
- fail("Could not instantiate ontology scope factory");
- OWLOntologyManager mgr = onm.getOntologyManagerFactory().createOntologyManager(true);
- try {
- src1 = new RootOntologySource(mgr.createOntology(baseIri), null);
- src2 = new RootOntologySource(mgr.createOntology(baseIri2), null);
- } catch (OWLOntologyCreationException e) {
- fail("Could not setup ontology with base IRI " + Constants.PEANUTS_MAIN_BASE);
- }
- }
-
- @Test
- public void testCreateSessionSpaceManual() throws Exception {
- OntologyScope scope = null;
- try {
- // we don't register it
- scope = scopeFactory.createOntologyScope(scopeIri1, src1, src2);
- scope.setUp();
- } catch (DuplicateIDException e) {
- fail("Unexpected DuplicateIDException was caught while testing scope "
- + e.getDulicateID());
- }
- assertNotNull(scope);
- Session ses = sesmgr.createSession();
- assertTrue(scope.getSessionSpaces().isEmpty());
- scope.addSessionSpace(spaceFactory
- .createSessionOntologySpace(scopeIri1), ses.getID());
- assertFalse(scope.getSessionSpaces().isEmpty());
- }
-
- @Test
- public void testCreateSessionSpaceAutomatic() {
- OntologyScope scope1 = null, scope2 = null, scope3 = null;
- try {
- scope1 = scopeFactory.createOntologyScope(scopeIri1, src1, src2);
- scopeRegistry.registerScope(scope1);
- scope2 = scopeFactory.createOntologyScope(scopeIri2, src2, src1);
- scopeRegistry.registerScope(scope2);
- scope3 = scopeFactory.createOntologyScope(scopeIri3, src2, src2);
- scopeRegistry.registerScope(scope3);
- // We do all activations after registering, otherwise the component
- // property value will override these activations.
- scopeRegistry.setScopeActive(scopeIri1, true);
- scopeRegistry.setScopeActive(scopeIri2, false);
- scopeRegistry.setScopeActive(scopeIri3, true);
- } catch (DuplicateIDException e) {
- fail("Unexpected DuplicateIDException was caught while testing scope "
- + e.getDulicateID());
- }
- Session ses = sesmgr.createSession();
- IRI sesid = ses.getID();
- assertFalse(scope1.getSessionSpaces().isEmpty());
- assertNotNull(scope1.getSessionSpace(sesid));
- assertFalse(scope3.getSessionSpaces().isEmpty());
- assertNull(scope2.getSessionSpace(sesid));
- assertNotNull(scope3.getSessionSpace(sesid));
- }
-
- @Test
- public void testRegisterSession() {
- int before = sesmgr.getRegisteredSessionIDs().size();
- Session ses = sesmgr.createSession();
- assertNotNull(ses);
- assertEquals(before + 1, sesmgr.getRegisteredSessionIDs().size());
- }
-
- @Test
- public void testSessionCreationDestruction() {
- int size = 100;
- int initialSize = sesmgr.getRegisteredSessionIDs().size();
- Set<Session> sessions = new HashSet<Session>();
- // Create and open many sessions.
- synchronized (sesmgr) {
- for (int i = 0; i < size; i++) {
- Session ses = sesmgr.createSession();
- try {
- ses.open();
- } catch (NonReferenceableSessionException e) {
- fail("Test method tried to open nonreferenceable session.");
- }
- sessions.add(ses);
- }
- // Check that 500 sessions have been created
- assertEquals(initialSize + size, sesmgr.getRegisteredSessionIDs()
- .size());
- }
- boolean open = true;
- for (Session ses : sessions)
- open &= ses.getSessionState() == State.ACTIVE;
- // Check that all created sessions have been opened
- assertTrue(open);
- // Kill 'em all, to quote Metallica
- synchronized (sesmgr) {
- for (Session ses : sessions)
- sesmgr.destroySession(ses.getID());
- assertEquals(initialSize, sesmgr.getRegisteredSessionIDs().size());
- }
- // Check that they are all zombies
- boolean zombi = true;
- for (Session ses : sessions)
- zombi &= ses.getSessionState() == State.ZOMBIE;
- assertTrue(zombi);
- // Try to resurrect them (hopefully failing)
- boolean resurrect = false;
- for (Session ses : sessions)
- try {
- ses.open();
- resurrect |= true;
- } catch (NonReferenceableSessionException e) {
- resurrect |= false;
- continue;
- }
- assertFalse(resurrect);
- }
+ public static IRI baseIri = IRI.create(Constants.PEANUTS_MAIN_BASE), baseIri2 = IRI
+ .create(Constants.PEANUTS_MINOR_BASE);
+
+ public static String scopeId1 = "Ranma12", scopeId2 = "HokutoNoKen", scopeId3 = "Doraemon";
+
+ private static OntologyScopeFactory scopeFactory = null;
+
+ private static ScopeRegistry scopeRegistry = null;
+
+ private static SessionManager sesmgr = null;
+
+ private static OntologySpaceFactory spaceFactory = null;
+
+ private static OntologyInputSource src1 = null, src2 = null;
+
+ @BeforeClass
+ public static void setup() {
+ // An ONManagerImpl with no store and default settings
+ ONManager onm = new ONManagerImpl(null, null, new Hashtable<String,Object>());
+ sesmgr = onm.getSessionManager();
+ scopeFactory = onm.getOntologyScopeFactory();
+ spaceFactory = onm.getOntologySpaceFactory();
+ scopeRegistry = onm.getScopeRegistry();
+ if (spaceFactory == null) fail("Could not instantiate ontology space factory");
+ if (scopeFactory == null) fail("Could not instantiate ontology scope factory");
+ OWLOntologyManager mgr = onm.getOntologyManagerFactory().createOntologyManager(true);
+ try {
+ src1 = new RootOntologySource(mgr.createOntology(baseIri), null);
+ src2 = new RootOntologySource(mgr.createOntology(baseIri2), null);
+ } catch (OWLOntologyCreationException e) {
+ fail("Could not setup ontology with base IRI " + Constants.PEANUTS_MAIN_BASE);
+ }
+ }
+
+ @Test
+ public void testCreateSessionSpaceManual() throws Exception {
+ OntologyScope scope = null;
+ try {
+ // we don't register it
+ scope = scopeFactory.createOntologyScope(scopeId1, src1, src2);
+ scope.setUp();
+ } catch (DuplicateIDException e) {
+ fail("Unexpected DuplicateIDException was caught while testing scope " + e.getDulicateID());
+ }
+ assertNotNull(scope);
+ Session ses = sesmgr.createSession();
+ assertTrue(scope.getSessionSpaces().isEmpty());
+ scope.addSessionSpace(spaceFactory.createSessionOntologySpace(scopeId1), ses.getID());
+ assertFalse(scope.getSessionSpaces().isEmpty());
+ }
+
+ @Test
+ public void testCreateSessionSpaceAutomatic() {
+ OntologyScope scope1 = null, scope2 = null, scope3 = null;
+ try {
+ scope1 = scopeFactory.createOntologyScope(scopeId1, src1, src2);
+ scopeRegistry.registerScope(scope1);
+ scope2 = scopeFactory.createOntologyScope(scopeId2, src2, src1);
+ scopeRegistry.registerScope(scope2);
+ scope3 = scopeFactory.createOntologyScope(scopeId3, src2, src2);
+ scopeRegistry.registerScope(scope3);
+ // We do all activations after registering, otherwise the component
+ // property value will override these activations.
+ scopeRegistry.setScopeActive(scopeId1, true);
+ scopeRegistry.setScopeActive(scopeId2, false);
+ scopeRegistry.setScopeActive(scopeId3, true);
+ } catch (DuplicateIDException e) {
+ fail("Unexpected DuplicateIDException was caught while testing scope " + e.getDulicateID());
+ }
+ Session ses = sesmgr.createSession();
+ IRI sesid = ses.getID();
+ assertFalse(scope1.getSessionSpaces().isEmpty());
+ assertNotNull(scope1.getSessionSpace(sesid));
+ assertFalse(scope3.getSessionSpaces().isEmpty());
+ assertNull(scope2.getSessionSpace(sesid));
+ assertNotNull(scope3.getSessionSpace(sesid));
+ }
+
+ @Test
+ public void testRegisterSession() {
+ int before = sesmgr.getRegisteredSessionIDs().size();
+ Session ses = sesmgr.createSession();
+ assertNotNull(ses);
+ assertEquals(before + 1, sesmgr.getRegisteredSessionIDs().size());
+ }
+
+ @Test
+ public void testSessionCreationDestruction() {
+ int size = 100;
+ int initialSize = sesmgr.getRegisteredSessionIDs().size();
+ Set<Session> sessions = new HashSet<Session>();
+ // Create and open many sessions.
+ synchronized (sesmgr) {
+ for (int i = 0; i < size; i++) {
+ Session ses = sesmgr.createSession();
+ try {
+ ses.open();
+ } catch (NonReferenceableSessionException e) {
+ fail("Test method tried to open nonreferenceable session.");
+ }
+ sessions.add(ses);
+ }
+ // Check that 500 sessions have been created
+ assertEquals(initialSize + size, sesmgr.getRegisteredSessionIDs().size());
+ }
+ boolean open = true;
+ for (Session ses : sessions)
+ open &= ses.getSessionState() == State.ACTIVE;
+ // Check that all created sessions have been opened
+ assertTrue(open);
+ // Kill 'em all, to quote Metallica
+ synchronized (sesmgr) {
+ for (Session ses : sessions)
+ sesmgr.destroySession(ses.getID());
+ assertEquals(initialSize, sesmgr.getRegisteredSessionIDs().size());
+ }
+ // Check that they are all zombies
+ boolean zombi = true;
+ for (Session ses : sessions)
+ zombi &= ses.getSessionState() == State.ZOMBIE;
+ assertTrue(zombi);
+ // Try to resurrect them (hopefully failing)
+ boolean resurrect = false;
+ for (Session ses : sessions)
+ try {
+ ses.open();
+ resurrect |= true;
+ } catch (NonReferenceableSessionException e) {
+ resurrect |= false;
+ continue;
+ }
+ assertFalse(resurrect);
+ }
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyRegistry.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyRegistry.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyRegistry.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyRegistry.java Thu Sep 29 18:10:56 2011
@@ -43,7 +43,6 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.semanticweb.owlapi.apibinding.OWLManager;
-import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.util.AutoIRIMapper;
@@ -53,7 +52,7 @@ import org.semanticweb.owlapi.util.AutoI
*/
public class TestOntologyRegistry {
- private IRI scopeIri = IRI.create(Locations.__STANBOL_ONT_NAMESPACE + "Scope");
+ private String scopeIri = "Scope";
private static RegistryIRISource ontologySource; // Null until the RegistryIRISource stays in place.
private static ONManager onm;
private static RegistryManager regman;
Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeOntologyResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeOntologyResource.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeOntologyResource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeOntologyResource.java Thu Sep 29 18:10:56 2011
@@ -16,8 +16,7 @@
*/
package org.apache.stanbol.ontologymanager.web.resources;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
+import static javax.ws.rs.core.Response.Status.*;
import java.net.URI;
import java.util.HashSet;
@@ -118,16 +117,17 @@ public class ONMScopeOntologyResource ex
if (!ontiri.isAbsolute()) ontiri = IRI.create(absur);
ScopeRegistry reg = onm.getScopeRegistry();
- OntologyScope scope = reg.getScope(sciri);
+ OntologyScope scope = reg.getScope(scopeid);
if (scope == null) return Response.status(NOT_FOUND).build();
// First of all, it could be a simple request for the space root!
- if (ontiri.equals(scope.getCoreSpace().getID())) {
+ String temp = scopeid + "/" + ontologyid;
+ if (temp.equals(scope.getCoreSpace().getID())) {
return Response.ok(scope.getCoreSpace().asOWLOntology()).build();
- } else if (ontiri.equals(scope.getCustomSpace().getID())) {
+ } else if (temp.equals(scope.getCustomSpace().getID())) {
return Response.ok(scope.getCustomSpace().asOWLOntology()).build();
- } else if (scope.getSessionSpace(ontiri) != null) {
- return Response.ok(scope.getSessionSpace(ontiri).asOWLOntology()).build();
+ } else if (scope.getSessionSpace(IRI.create(temp)) != null) {
+ return Response.ok(scope.getSessionSpace(IRI.create(temp)).asOWLOntology()).build();
}
/*
@@ -189,7 +189,7 @@ public class ONMScopeOntologyResource ex
ScopeRegistry reg = onm.getScopeRegistry();
String scopeID = uriInfo.getAbsolutePath().toString();
scopeID = scopeID.substring(0, scopeID.lastIndexOf("/"));
- OntologyScope scope = reg.getScope(IRI.create(scopeID));
+ OntologyScope scope = reg.getScope(scopeID);
if (scope == null) return Response.status(404).build();
@@ -314,15 +314,15 @@ public class ONMScopeOntologyResource ex
IRI ontIri = IRI.create(ontologyid);
ScopeRegistry reg = onm.getScopeRegistry();
- OntologyScope scope = reg.getScope(scopeIri);
+ OntologyScope scope = reg.getScope(scopeId);
OntologySpace cs = scope.getCustomSpace();
if (cs.hasOntology(ontIri)) {
try {
- reg.setScopeActive(scopeIri, false);
+ reg.setScopeActive(scopeId, false);
cs.removeOntology(new RootOntologySource(cs.getOntology(ontIri)));
- reg.setScopeActive(scopeIri, true);
+ reg.setScopeActive(scopeId, true);
} catch (OntologySpaceModificationException e) {
- reg.setScopeActive(scopeIri, true);
+ reg.setScopeActive(scopeId, true);
throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
}
}
Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeResource.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeResource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeResource.java Thu Sep 29 18:10:56 2011
@@ -51,6 +51,7 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry;
import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
+import org.apache.stanbol.ontologymanager.ontonet.impl.util.StringUtils;
import org.apache.stanbol.ontologymanager.registry.api.RegistryLoader;
import org.apache.stanbol.ontologymanager.registry.api.RegistryManager;
import org.apache.stanbol.ontologymanager.registry.impl.RegistryLoaderImpl;
@@ -97,8 +98,7 @@ public class ONMScopeResource extends Ba
@Context ServletContext servletContext) {
ScopeRegistry reg = onm.getScopeRegistry();
-
- OntologyScope scope = reg.getScope(IRI.create(uriInfo.getAbsolutePath()));
+ OntologyScope scope = reg.getScope(scopeid/* IRI.create(uriInfo.getAbsolutePath()) */);
if (scope == null) return;
reg.deregisterScope(scope);
}
@@ -106,11 +106,12 @@ public class ONMScopeResource extends Ba
@GET
@Produces(value = {KRFormat.RDF_XML, KRFormat.OWL_XML, KRFormat.TURTLE, KRFormat.FUNCTIONAL_OWL,
KRFormat.MANCHESTER_OWL, KRFormat.RDF_JSON})
- public Response getTopOntology(@Context UriInfo uriInfo,
+ public Response getTopOntology(@PathParam("scopeid") String scopeid,
+ @Context UriInfo uriInfo,
@Context HttpHeaders headers,
@Context ServletContext servletContext) {
ScopeRegistry reg = onm.getScopeRegistry();
- OntologyScope scope = reg.getScope(IRI.create(uriInfo.getAbsolutePath()));
+ OntologyScope scope = reg.getScope(scopeid/* IRI.create(uriInfo.getAbsolutePath()) */);
if (scope == null) return Response.status(NOT_FOUND).build();
else return Response.ok(scope.asOWLOntology()).build();
}
@@ -135,13 +136,13 @@ public class ONMScopeResource extends Ba
// Malformed IRI, throw bad request.
throw new WebApplicationException(ex, BAD_REQUEST);
}
- if (reg.containsScope(scopeiri)) {
- OntologyScope scope = reg.getScope(scopeiri);
+ if (reg.containsScope(scopeid)) {
+ OntologyScope scope = reg.getScope(scopeid);
try {
OntologyInputSource src = new RootOntologyIRISource(ontoiri);
OntologySpace space = scope.getCustomSpace();
if (space == null) {
- space = onm.getOntologySpaceFactory().createCustomOntologySpace(scopeiri, src);
+ space = onm.getOntologySpaceFactory().createCustomOntologySpace(scopeid, src);
scope.setCustomSpace(space);
// space.setUp();
@@ -227,8 +228,8 @@ public class ONMScopeResource extends Ba
IRI scopeId = IRI.create(uriInfo.getAbsolutePath());
// Invoke the appropriate factory method depending on the
// availability of a custom source.
- scope = (custSrc != null) ? f.createOntologyScope(scopeId, coreSrc, custSrc) : f
- .createOntologyScope(scopeId, coreSrc);
+ scope = (custSrc != null) ? f.createOntologyScope(scopeid, coreSrc, custSrc) : f
+ .createOntologyScope(scopeid, coreSrc);
// Setup and register the scope. If no custom space was set, it will
// still be open for modification.
scope.setUp();
@@ -237,7 +238,7 @@ public class ONMScopeResource extends Ba
if (activate != null && !activate.equals("")) {
activateBool = Boolean.valueOf(activate);
}
- reg.setScopeActive(scopeId, activateBool);
+ reg.setScopeActive(scopeid, activateBool);
} catch (DuplicateIDException e) {
throw new WebApplicationException(e, CONFLICT);
} catch (Exception ex) {
Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/SessionResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/SessionResource.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/SessionResource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/SessionResource.java Thu Sep 29 18:10:56 2011
@@ -91,7 +91,7 @@ public class SessionResource extends Bas
ScopeRegistry scopeRegistry = onm.getScopeRegistry();
- OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
+ OntologyScope ontologyScope = scopeRegistry.getScope(scope);
SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionIRI);
try {
sos.addOntology(new RootOntologySource(ontology));
@@ -134,7 +134,7 @@ public class SessionResource extends Bas
IRI ontologyIRI = IRI.create(location);
ScopeRegistry scopeRegistry = onm.getScopeRegistry();
- OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
+ OntologyScope ontologyScope = scopeRegistry.getScope(scope);
SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionIRI);
try {
sos.addOntology(new RootOntologyIRISource(ontologyIRI));
@@ -176,13 +176,13 @@ public class SessionResource extends Bas
* Then retrieve the ontology scope.
*/
IRI scopeIRI = IRI.create(scope);
- OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
+ OntologyScope ontologyScope = scopeRegistry.getScope(scope);
/*
* Finally associate the KReS session to the scope.
*/
OntologySpaceFactory ontologySpaceFactory = onm.getOntologySpaceFactory();
- SessionOntologySpace sessionOntologySpace = ontologySpaceFactory.createSessionOntologySpace(scopeIRI);
+ SessionOntologySpace sessionOntologySpace = ontologySpaceFactory.createSessionOntologySpace(scope);
try {
ontologyScope.addSessionSpace(sessionOntologySpace, ses.getID());
} catch (UnmodifiableOntologySpaceException e) {
@@ -218,7 +218,7 @@ public class SessionResource extends Bas
ScopeRegistry scopeRegistry = onm.getScopeRegistry();
- OntologyScope ontologyScope = scopeRegistry.getScope(scopeID);
+ OntologyScope ontologyScope = scopeRegistry.getScope(scope);
SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionID);
try {
Modified: incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java (original)
+++ incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ReasoningServiceTaskResource.java Thu Sep 29 18:10:56 2011
@@ -602,7 +602,7 @@ public class ReasoningServiceTaskResourc
// We must know both scope and session
IRI scopeIRI = IRI.create(scopeID);
- OntologyScope scope = onm.getScopeRegistry().getScope(scopeIRI);
+ OntologyScope scope = onm.getScopeRegistry().getScope(scopeID);
if (scope == null) {
log.error("Scope {} cannot be retrieved", sessionID);
throw new WebApplicationException(Response.Status.NOT_FOUND);
Modified: incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBExtractor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBExtractor.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBExtractor.java (original)
+++ incubator/stanbol/trunk/reengineer/db/src/main/java/org/apache/stanbol/reengineer/db/DBExtractor.java Thu Sep 29 18:10:56 2011
@@ -51,9 +51,9 @@ import org.slf4j.LoggerFactory;
public class DBExtractor implements Reengineer {
public static final String _DB_DATA_REENGINEERING_SESSION_DEFAULT = "/db-data-reengineering-session";
- public static final String _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT = "/db-data-reengineering-session-space";
- public static final String _DB_REENGINEERING_SESSION_SPACE_DEFAULT = "/db-schema-reengineering-session-space";
- public static final String _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT = "/db-schema-reengineering-ontology-space";
+// public static final String _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT = "/db-data-reengineering-session-space";
+// public static final String _DB_REENGINEERING_SESSION_SPACE_DEFAULT = "/db-schema-reengineering-session-space";
+// public static final String _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT = "/db-schema-reengineering-ontology-space";
public static final String _DB_SCHEMA_REENGINEERING_SESSION_DEFAULT = "/db-schema-reengineering-session";
public static final String _HOST_NAME_AND_PORT_DEFAULT = "localhost:8080";
public static final String _REENGINEERING_SCOPE_DEFAULT = "db_reengineering";
@@ -61,14 +61,14 @@ public class DBExtractor implements Reen
@Property(value = _DB_DATA_REENGINEERING_SESSION_DEFAULT)
public static final String DB_DATA_REENGINEERING_SESSION = "org.apache.stanbol.reengineer.db.data";
- @Property(value = _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT)
- public static final String DB_DATA_REENGINEERING_SESSION_SPACE = "org.apache.stanbol.reengineer.space.db.data";
+// @Property(value = _DB_DATA_REENGINEERING_SESSION_SPACE_DEFAULT)
+// public static final String DB_DATA_REENGINEERING_SESSION_SPACE = "org.apache.stanbol.reengineer.space.db.data";
+//
+// @Property(value = _DB_REENGINEERING_SESSION_SPACE_DEFAULT)
+// public static final String DB_REENGINEERING_SESSION_SPACE = "http://kres.iks-project.eu/space/reengineering/db";
- @Property(value = _DB_REENGINEERING_SESSION_SPACE_DEFAULT)
- public static final String DB_REENGINEERING_SESSION_SPACE = "http://kres.iks-project.eu/space/reengineering/db";
-
- @Property(value = _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT)
- public static final String DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE = "org.apache.stanbol.reengineer.ontology.space.db";
+// @Property(value = _DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE_DEFAULT)
+// public static final String DB_SCHEMA_REENGINEERING_ONTOLOGY_SPACE = "org.apache.stanbol.reengineer.ontology.space.db";
@Property(value = _DB_SCHEMA_REENGINEERING_SESSION_DEFAULT)
public static final String DB_SCHEMA_REENGINEERING_SESSION = "org.apache.stanbol.reengineer.db.schema";
@@ -83,7 +83,7 @@ public class DBExtractor implements Reen
String databaseURI;
- private IRI kReSSessionID;
+// private IRI kReSSessionID;
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -93,7 +93,7 @@ public class DBExtractor implements Reen
@Reference
ReengineerManager reengineeringManager;
- private IRI reengineeringScopeIRI;
+ private String reengineeringScopeID;
private IRI reengineeringSpaceIRI;
@@ -173,8 +173,8 @@ public class DBExtractor implements Reen
}
protected void activate(Dictionary<String,Object> configuration) {
-
- String reengineeringScopeID = (String) configuration.get(REENGINEERING_SCOPE);
+/*
+ String */reengineeringScopeID = (String) configuration.get(REENGINEERING_SCOPE);
if (reengineeringScopeID == null) reengineeringScopeID = _REENGINEERING_SCOPE_DEFAULT;
String hostNameAndPort = (String) configuration.get(HOST_NAME_AND_PORT);
if (hostNameAndPort == null) hostNameAndPort = _HOST_NAME_AND_PORT_DEFAULT;
@@ -182,16 +182,16 @@ public class DBExtractor implements Reen
hostNameAndPort = "http://" + hostNameAndPort;
- reengineeringScopeIRI = IRI.create(hostNameAndPort + "/kres/ontoman/ontology/ontology/"
- + reengineeringScopeID);
- reengineeringSpaceIRI = IRI.create(DB_REENGINEERING_SESSION_SPACE);
+// reengineeringScopeID = IRI.create(hostNameAndPort + "/kres/ontoman/ontology/ontology/"
+// + reengineeringScopeID);
+// reengineeringSpaceIRI = IRI.create(DB_REENGINEERING_SESSION_SPACE);
reengineeringManager.bindReengineer(this);
SessionManager kReSSessionManager = onManager.getSessionManager();
Session kReSSession = kReSSessionManager.createSession();
- kReSSessionID = kReSSession.getID();
+// kReSSessionID = kReSSession.getID();
OntologyScopeFactory ontologyScopeFactory = onManager.getOntologyScopeFactory();
@@ -207,7 +207,7 @@ public class DBExtractor implements Reen
OWLOntology owlOntology = ontologyManager.createOntology(iri);
log.info("Ontology {} created.", iri);
- scope = ontologyScopeFactory.createOntologyScope(reengineeringScopeIRI,
+ scope = ontologyScopeFactory.createOntologyScope(reengineeringScopeID,
new RootOntologyIRISource(IRI.create(DBS_L1.URI)));
// scope.setUp();
@@ -216,7 +216,7 @@ public class DBExtractor implements Reen
} catch (DuplicateIDException e) {
log.info("Semion DBExtractor : already existing scope for IRI " + REENGINEERING_SCOPE);
- scope = scopeRegistry.getScope(reengineeringScopeIRI);
+ scope = scopeRegistry.getScope(reengineeringScopeID);
} catch (OWLOntologyCreationException e) {
log.error("Failed to creare ontology " + DBS_L1.URI, e);
} catch (Exception e) {
@@ -225,11 +225,11 @@ public class DBExtractor implements Reen
if (scope != null) {
try {
- scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(reengineeringSpaceIRI),
+ scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(this.reengineeringScopeID),
kReSSession.getID());
- scopeRegistry.setScopeActive(reengineeringScopeIRI, true);
+ scopeRegistry.setScopeActive(reengineeringScopeID, true);
} catch (UnmodifiableOntologySpaceException ex) {
- log.error("Cannot add session space " + reengineeringSpaceIRI + " to unmodifiable scope "
+ log.error("Cannot add session space for scope " + reengineeringScopeID + " to unmodifiable scope "
+ scope, ex);
}
}
@@ -293,8 +293,8 @@ public class DBExtractor implements Reen
ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
- if (scopeRegistry.isScopeActive(reengineeringScopeIRI)) {
- ontologyScope = scopeRegistry.getScope(reengineeringScopeIRI);
+ if (scopeRegistry.isScopeActive(reengineeringScopeID)) {
+ ontologyScope = scopeRegistry.getScope(reengineeringScopeID);
}
return ontologyScope;
Modified: incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java?rev=1177383&r1=1177382&r2=1177383&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java (original)
+++ incubator/stanbol/trunk/reengineer/xml/src/main/java/org/apache/stanbol/reengineer/xml/XMLExtractor.java Thu Sep 29 18:10:56 2011
@@ -81,7 +81,7 @@ public class XMLExtractor extends Reengi
public static final String _HOST_NAME_AND_PORT_DEFAULT = "localhost:8080";
public static final String _REENGINEERING_SCOPE_DEFAULT = "xml_reengineering";
- public static final String _XML_REENGINEERING_SESSION_SPACE_DEFAULT = "/xml-reengineering-session-space";
+// public static final String _XML_REENGINEERING_SESSION_SPACE_DEFAULT = "/xml-reengineering-session-space";
@Property(value = _HOST_NAME_AND_PORT_DEFAULT)
public static final String HOST_NAME_AND_PORT = "host.name.port";
@@ -89,10 +89,8 @@ public class XMLExtractor extends Reengi
@Property(value = _REENGINEERING_SCOPE_DEFAULT)
public static final String REENGINEERING_SCOPE = "xml.reengineering.scope";
- @Property(value = _XML_REENGINEERING_SESSION_SPACE_DEFAULT)
- public static final String XML_REENGINEERING_SESSION_SPACE = "http://kres.iks-project.eu/space/reengineering/db";
-
- private IRI kReSSessionID;
+// @Property(value = _XML_REENGINEERING_SESSION_SPACE_DEFAULT)
+// public static final String XML_REENGINEERING_SESSION_SPACE = "http://kres.iks-project.eu/space/reengineering/db";
public final Logger log = LoggerFactory.getLogger(getClass());
@@ -103,8 +101,8 @@ public class XMLExtractor extends Reengi
ReengineerManager reengineeringManager;
private OntologyScope scope;
- private IRI scopeIRI;
- private IRI spaceIRI;
+ private String scopeID;
+// private IRI spaceIRI;
/**
* This default constructor is <b>only</b> intended to be used by the OSGI environment with Service
@@ -143,21 +141,22 @@ public class XMLExtractor extends Reengi
}
protected void activate(Dictionary<String,Object> configuration) {
- String scopeID = (String) configuration.get(REENGINEERING_SCOPE);
+ /*String*/
+ scopeID = (String) configuration.get(REENGINEERING_SCOPE);
if (scopeID == null) scopeID = _REENGINEERING_SCOPE_DEFAULT;
String hostPort = (String) configuration.get(HOST_NAME_AND_PORT);
if (hostPort == null) hostPort = _HOST_NAME_AND_PORT_DEFAULT;
// TODO: Manage the other properties
- spaceIRI = IRI.create(XML_REENGINEERING_SESSION_SPACE);
- scopeIRI = IRI.create("http://" + hostPort + "/kres/ontology/" + scopeID);
+// spaceIRI = IRI.create(XML_REENGINEERING_SESSION_SPACE);
+// scopeID = IRI.create("http://" + hostPort + "/kres/ontology/" + scopeID);
reengineeringManager.bindReengineer(this);
SessionManager kReSSessionManager = onManager.getSessionManager();
Session kReSSession = kReSSessionManager.createSession();
- kReSSessionID = kReSSession.getID();
+// sessionId = kReSSession.getID();
OntologyScopeFactory ontologyScopeFactory = onManager.getOntologyScopeFactory();
@@ -173,7 +172,7 @@ public class XMLExtractor extends Reengi
OWLOntology owlOntology = ontologyManager.createOntology(iri);
log.info("Ontology {} created.", iri);
- scope = ontologyScopeFactory.createOntologyScope(scopeIRI,
+ scope = ontologyScopeFactory.createOntologyScope(scopeID,
new RootOntologyIRISource(IRI.create(XML_OWL.URI))
/* new OntologyInputSourceOXML() */);
// scope.setUp();
@@ -181,7 +180,7 @@ public class XMLExtractor extends Reengi
scopeRegistry.registerScope(scope);
} catch (DuplicateIDException e) {
log.info("Semion DBExtractor : already existing scope for IRI " + REENGINEERING_SCOPE);
- scope = onManager.getScopeRegistry().getScope(scopeIRI);
+ scope = onManager.getScopeRegistry().getScope(scopeID);
} catch (OWLOntologyCreationException e) {
log.error("Failed to creare ontology " + XML_OWL.URI, e);
} catch (Exception e) {
@@ -190,12 +189,12 @@ public class XMLExtractor extends Reengi
if (scope != null) {
try {
- scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(spaceIRI),
+ scope.addSessionSpace(ontologySpaceFactory.createSessionOntologySpace(scopeID),
kReSSession.getID());
- scopeRegistry.setScopeActive(scopeIRI, true);
+ scopeRegistry.setScopeActive(scopeID, true);
} catch (UnmodifiableOntologySpaceException ex) {
- log.error("Cannot add session space " + spaceIRI + " to unmodifiable scope " + scope, ex);
+ log.error("Cannot add session space for " + scopeID + " to unmodifiable scope " + scope, ex);
}
}
@@ -516,8 +515,8 @@ public class XMLExtractor extends Reengi
ScopeRegistry scopeRegistry = onManager.getScopeRegistry();
- if (scopeRegistry.isScopeActive(scopeIRI)) {
- ontologyScope = scopeRegistry.getScope(scopeIRI);
+ if (scopeRegistry.isScopeActive(scopeID)) {
+ ontologyScope = scopeRegistry.getScope(scopeID);
}
return ontologyScope;