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/07/22 20:37:17 UTC
svn commit: r1149687 [1/2] - in
/incubator/stanbol/trunk/ontologymanager/ontonet/src:
main/java/org/apache/stanbol/ontologymanager/ontonet/api/
main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/
main/java/org/apache/stanbol/ontologymana...
Author: alexdma
Date: Fri Jul 22 18:37:10 2011
New Revision: 1149687
URL: http://svn.apache.org/viewvc?rev=1149687&view=rev
Log:
STANBOL-285 :
- RegistryManagerImpl now populates the model internally via a two-pass axiom-visiting algorithm.
- Implemented union/merging of library content from multiple registries.
- Deprecated classes and methods that should no longer be used.
- Added javadoc for entire registry API
Added:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/IllegalRegistryCycleException.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOperation.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/RegistryIRISource.java
- copied, changed from r1149632, incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/OntologyRegistryIRISource.java
Removed:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/IRIRegistrySource.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/OntologyRegistryIRISource.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/XDRegistrySource.java
Modified:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManagerConfiguration.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryItemFactory.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/LibrarySource.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryItemFactoryImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryManagerImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/cache/RegistryUtils.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/AbstractRegistryItem.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/LibraryImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/model/RegistryOntologyImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/Locations.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/StructureTest.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestIndexing.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyLibrary.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/registry/TestOntologyRegistry.java
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManagerConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManagerConfiguration.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManagerConfiguration.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManagerConfiguration.java Fri Jul 22 18:37:10 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.api;
import java.io.File;
@@ -22,9 +22,6 @@ import java.util.List;
/**
* Provides the configuration needed for the {@link ONManager}. A configuration should only be handled
* internally by the {@link ONManager} implementation.
- *
- * @author alessandro
- *
*/
public interface ONManagerConfiguration {
Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/IllegalRegistryCycleException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/IllegalRegistryCycleException.java?rev=1149687&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/IllegalRegistryCycleException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/IllegalRegistryCycleException.java Fri Jul 22 18:37:10 2011
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.registry;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
+
+/**
+ * Thrown when an attempt to create an illegal cycle in the registry item model is detected. Examples of
+ * illegal cycle include being both a parent and a child of the same registry item, or a parent or child of
+ * itself.
+ */
+public class IllegalRegistryCycleException extends RegistryContentException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2929796860026423332L;
+
+ private RegistryOperation operationType;
+
+ private RegistryItem sourceNode, targetNode;
+
+ /**
+ * Creates a new instance of {@link IllegalRegistryCycleException}.
+ *
+ * @param sourceNode
+ * the source node of the cycle.
+ * @param targetNode
+ * the target node of the cycle.
+ * @param operationType
+ * the type of operation attempted, i.e. the disallowed arc of the cycle.
+ */
+ public IllegalRegistryCycleException(RegistryItem sourceNode,
+ RegistryItem targetNode,
+ RegistryOperation operationType) {
+ super("Cycles of type " + operationType + " between registry items " + sourceNode + " and "
+ + targetNode + " are not allowed.");
+ this.sourceNode = sourceNode;
+ this.targetNode = targetNode;
+ }
+
+ /**
+ * Returns the type of operation attempted, i.e. the disallowed arc of this cycle.
+ *
+ * @return the type of operation attempted.
+ */
+ public RegistryOperation getOperationType() {
+ return operationType;
+ }
+
+ /**
+ * Returns the source node of this cycle.
+ *
+ * @return the source node of the cycle.
+ */
+ public RegistryItem getSourceNode() {
+ return sourceNode;
+ }
+
+ /**
+ * Returns the target node of this cycle.
+ *
+ * @return the target node of the cycle.
+ */
+ public RegistryItem getTargetNode() {
+ return targetNode;
+ }
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/LibraryContentNotLoadedException.java Fri Jul 22 18:37:10 2011
@@ -30,6 +30,8 @@ public class LibraryContentNotLoadedExce
*/
private static final long serialVersionUID = 4442769260608567120L;
+ private Library library;
+
/**
* Creates a new instance of {@link LibraryContentNotLoadedException}.
*
@@ -41,8 +43,6 @@ public class LibraryContentNotLoadedExce
this.library = library;
}
- private Library library;
-
/**
* Returns the library whose content was requested that is not loaded yet.
*
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentException.java Fri Jul 22 18:37:10 2011
@@ -16,17 +16,33 @@
*/
package org.apache.stanbol.ontologymanager.ontonet.api.registry;
+/**
+ * Thrown when trying to process an invalid registry item. The reason why it is invalid can be specified by
+ * the cause, message or subclasses of this exception.
+ */
public class RegistryContentException extends Exception {
/**
- *
- */
+ *
+ */
private static final long serialVersionUID = 1L;
+ /**
+ * Creates a new instance of {@link RegistryContentException}.
+ *
+ * @param cause
+ * the throwable that caused this exception to be thrown.
+ */
public RegistryContentException(Throwable cause) {
initCause(cause);
}
+ /**
+ * Creates a new instance of {@link RegistryContentException}.
+ *
+ * @param message
+ * the exception message.
+ */
public RegistryContentException(String message) {
super(message);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryContentListener.java Fri Jul 22 18:37:10 2011
@@ -18,8 +18,18 @@ package org.apache.stanbol.ontologymanag
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
+/**
+ * Object that react to direct content requests to ontology registry items will implement this interface.
+ */
public interface RegistryContentListener {
+ /**
+ * Called when a registry item receives a request for some resource in its content, regardless whether the
+ * actual resource has been previously loaded.
+ *
+ * @param requestTarget
+ * the registry item that was requested.
+ */
void registryContentRequested(RegistryItem requestTarget);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryItemFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryItemFactory.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryItemFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryItemFactory.java Fri Jul 22 18:37:10 2011
@@ -21,22 +21,17 @@ import java.util.Set;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
-import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.RegistryUtils;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLOntology;
/**
- * A factory that creates the basic elements of the ontology registry metamodel, starting from OWL objects
- * that are required not to be anonymous.<br/>
+ * A factory that creates the basic elements of the ontology registry metamodel from OWL objects that are
+ * required not to be anonymous.<br/>
* <br/>
* <b>Note that implementations should not be aggressive</b>, in that they should <b>not</b> recursively
- * create and/or append the parents and children of any generated object. Refer to the following static
- * methods in the {@link RegistryUtils} class to recursively populate a registry item:
- * <ul>
- * <li>{@link RegistryUtils#populateLibrary(OWLNamedIndividual, Set)}</li>
- * <li>{@link RegistryUtils#populateOntology(OWLNamedIndividual, Set)}</li>
- * <li>{@link RegistryUtils#populateRegistry(OWLOntology)}</li>
- * </ul>
+ * create and/or append the parents and children of any generated object. Refer to
+ * {@link RegistryManager#createModel(Set)} to recursively populate registry item starting from a set of
+ * registries.
*/
public interface RegistryItemFactory {
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java Fri Jul 22 18:37:10 2011
@@ -34,28 +34,59 @@ import org.semanticweb.owlapi.model.OWLO
*/
public interface RegistryLoader {
- Set<OWLOntology> gatherOntologies(RegistryItem registryItem,
- OWLOntologyManager manager,
- boolean recurseRegistries) throws OWLOntologyCreationException;
+ /**
+ * Loads all the OWL ontologies referenced by <code>registryItem</code>.
+ *
+ * @param registryItem
+ * the parent registry item.
+ * @param manager
+ * the OWL ontology manager to use for loading (e.g. to avoid reloading ontologies).
+ * @param recurse
+ * if true, load also ontologies that are indirectly referenced (e.g. if
+ * <code>registryItem</code> is a {@link Registry}).
+ * @return
+ * @throws OWLOntologyCreationException
+ */
+ Set<OWLOntology> gatherOntologies(RegistryItem registryItem, OWLOntologyManager manager, boolean recurse) throws OWLOntologyCreationException;
+ /**
+ * @deprecated obsolete. Refer to {@link Registry#getChild(IRI)} instead.
+ */
Library getLibrary(Registry reg, IRI libraryID);
+ /**
+ * @deprecated obsolete. Refer to {@link RegistryItem#getParent(IRI)} instead.
+ */
Object getParent(Object child);
+ /**
+ * @deprecated obsolete. Refer to {@link RegistryItem#hasChildren()} instead.
+ */
boolean hasChildren(Object parent);
+ /**
+ * @deprecated obsolete. Refer to {@link Registry#getChild(IRI)} instead.
+ */
boolean hasLibrary(Registry reg, IRI libraryID);
/**
- * Only extract the ontologies belonging to the library specified, if found in the registry at the
+ * Only extracts the ontologies belonging to the library specified, if found in the registry at the
* supplied location.
*
* @param registryPhysicalRIRI
* @param libraryID
* @return
+ * @deprecated This method does not what is supposed to do (ontology loading is selective, not model
+ * construction). Calls to this method should be replaced by the sequence:
+ * {@link RegistryManager#createModel(Set)} and {@link RegistryManager#getRegistry(IRI)}.
*/
- Registry loadLibraryEager(IRI registryPhysicalIRI, IRI libraryID);
+ Registry loadLibrary(IRI registryPhysicalIRI, IRI libraryID);
+ /**
+ *
+ * @throws RegistryContentException
+ * @deprecated obsolete
+ */
void loadLocations() throws RegistryContentException;
/**
@@ -63,6 +94,8 @@ public interface RegistryLoader {
*
* @param physicalIRI
* @return
+ * @deprecated Calls to this method should be replaced by the sequence:
+ * {@link RegistryManager#createModel(Set)} and {@link RegistryManager#getRegistry(IRI)}.
*/
Registry loadRegistry(IRI registryPhysicalIRI, OWLOntologyManager mgr);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryManager.java Fri Jul 22 18:37:10 2011
@@ -22,7 +22,6 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLOntology;
/**
@@ -30,34 +29,114 @@ import org.semanticweb.owlapi.model.OWLO
*/
public interface RegistryManager {
+ /**
+ * The key used to configure the caching policy of the registry manager.
+ */
public String CACHING_POLICY = "org.apache.stanbol.ontologymanager.ontonet.registryCaching";
+ /**
+ * The key used to configure the ontology loading policy of the registry manager.
+ */
public String LAZY_LOADING = "org.apache.stanbol.ontologymanager.ontonet.registryLazy";
+ /**
+ * The key used to configure the locations of the registries to be scanned by the registry manager.
+ */
public String REGISTRY_LOCATIONS = "org.apache.stanbol.ontologymanager.ontonet.registryLocations";
+ /**
+ * Adds a registry to the set of ontology registries managed by this object.
+ *
+ * @param registry
+ * the ontology registry to be added.
+ */
void addRegistry(Registry registry);
+ /**
+ * Clears the set of ontology registries managed by this object.
+ */
void clearRegistries();
+ /**
+ * Constructs the models of all the registry items discovered by scanning the supplied ontologies that are
+ * supposed to denote registries. <br/>
+ * <br/>
+ * To denote a registry, an ontology must instantiate the metamodel at <a
+ * href="http://www.ontologydesignpatterns.org/schemas/meta.owl"
+ * >http://www.ontologydesignpatterns.org/schemas/meta.owl</a> <br/>
+ * <br/>
+ * Depending on implementations, this method may or may not be automatically invoked after a call to
+ * methods that determine changes to the model.
+ *
+ * @param registryOntologies
+ * the source OWL ontologies that describe the registries. If any of these denotes an invalid
+ * registry, a {@link RegistryContentException} will be thrown. If it does not denote a
+ * registry at all, it will be skipped.
+ * @return the ontology registries that are the parent items of the entire model.
+ */
+ Set<Registry> createModel(Set<OWLOntology> registryOntologies);
+
+ /**
+ * Returns all the libraries that contain the ontology with the given identifier.
+ *
+ * @param ontologyID
+ * the ontology identifier.
+ * @return the set of libraries that contain the ontology.
+ */
Set<Library> getLibraries(IRI ontologyID);
+ /**
+ * Returns the set of registries managed by this object.
+ *
+ * @return the set of all managed registries.
+ */
Set<Registry> getRegistries();
+ /**
+ * Returns all the registries that reference the library with the given identifier.
+ *
+ * @return the set of all managed registries.
+ */
Set<Registry> getRegistries(IRI libraryID);
+ /**
+ * Returns the registry with the given identifier, if present.<br/>
+ * <br/>
+ * NOTE THAT IF THE REGISTRY ITEM EXIST BUT IS NOT A REGISTRY, THIS METHOD WILL RETURN NULL.
+ *
+ * @param id
+ * the registry identifier.
+ * @return the registry with the given identifier, or null if not present.
+ */
Registry getRegistry(IRI id);
+ /**
+ * Determines if the registry manager is set to load its resources only when a specific request for them
+ * (e.g. by a call to {@link RegistryOntology#asOWLOntology()} or {@link Library#getOntologies()} is
+ * issued).
+ *
+ * @return true if set to load resources only upon request, false if set to load all resources eagerly
+ * when the model has been built.
+ */
boolean isLazyLoading();
- Library populateLibrary(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException;
-
- RegistryOntology populateOntology(OWLNamedIndividual ind, Set<OWLOntology> registries) throws RegistryContentException;
-
- Registry populateRegistry(OWLOntology registry) throws RegistryContentException;
-
+ /**
+ * Removes a registry from the set of ontology registries managed by this object.
+ *
+ * @param registry
+ * the ontology registry to be removed.
+ */
void removeRegistry(IRI registryId);
+ /**
+ * Sets the resource loading policy of this registry manager. There is no guarantee that setting a policy
+ * after a model has already been created will affect the existing model (i.e. unload all its ontologies
+ * if true, load them if false), but it will affect any subsequent calls to {@link #createModel(Set)}.
+ *
+ * @param lazy
+ * if true, the registry manager will be set to load resources only upon request, otherwise it
+ * will be set to load all resources eagerly when the model has been built.
+ */
void setLazyLoading(boolean lazy);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOntologyNotLoadedException.java Fri Jul 22 18:37:10 2011
@@ -16,8 +16,18 @@
*/
package org.apache.stanbol.ontologymanager.ontonet.api.registry;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryOntology;
+/**
+ * Thrown whenever there is a request for the raw OWL version of a registry ontology which has not been loaded
+ * yet (e.g. due to lazy loading policies). Developers who catch this exception may, for example, decide to
+ * load the ontology.<br/>
+ * <br/>
+ * Note that this exception is independent from calls to
+ * {@link RegistryContentListener#registryContentRequested(RegistryItem)}, although it can be expected to be
+ * thrown thereafter.
+ */
public class RegistryOntologyNotLoadedException extends RegistryContentException {
/**
@@ -27,11 +37,22 @@ public class RegistryOntologyNotLoadedEx
private RegistryOntology ontology;
+ /**
+ * Creates a new instance of {@link RegistryOntologyNotLoadedException}.
+ *
+ * @param library
+ * the ontology that caused the exception.
+ */
public RegistryOntologyNotLoadedException(RegistryOntology ontology) {
super(ontology.getName());
this.ontology = ontology;
}
+ /**
+ * Returns the requested ontology that is not loaded yet.
+ *
+ * @return the ontology that caused the exception.
+ */
public RegistryOntology getOntology() {
return ontology;
}
Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOperation.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOperation.java?rev=1149687&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOperation.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryOperation.java Fri Jul 22 18:37:10 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.registry;
+
+/**
+ * The possible types of operations that can be performed with registry items.
+ */
+public enum RegistryOperation {
+
+ /**
+ * The addition of a registry item as a parent of another registry item.
+ */
+ ADD_CHILD,
+
+ /**
+ * The addition of a registry item as a child of another registry item.
+ */
+ ADD_PARENT;
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/LibrarySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/LibrarySource.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/LibrarySource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/LibrarySource.java Fri Jul 22 18:37:10 2011
@@ -110,7 +110,7 @@ public class LibrarySource extends Abstr
bindPhysicalIri(null);
Set<OWLOntology> subtrees = new HashSet<OWLOntology>();
- Registry reg = loader.loadLibraryEager(registryLocation, libraryID);
+ Registry reg = loader.loadLibrary(registryLocation, libraryID);
for (RegistryItem ri : reg.getChildren()) {
if (ri.isLibrary()) try {
Set<OWLOntology> adds = loader.gatherOntologies(ri, ontologyManager, true);
Copied: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/RegistryIRISource.java (from r1149632, incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/OntologyRegistryIRISource.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/RegistryIRISource.java?p2=incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/RegistryIRISource.java&p1=incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/OntologyRegistryIRISource.java&r1=1149632&r2=1149687&rev=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/OntologyRegistryIRISource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/RegistryIRISource.java Fri Jul 22 18:37:10 2011
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
* the ontology registry obtained by dereferencing a supplied IRI.
*
*/
-public class OntologyRegistryIRISource extends AbstractOntologyInputSource {
+public class RegistryIRISource extends AbstractOntologyInputSource {
private Logger log = LoggerFactory.getLogger(getClass());
@@ -50,9 +50,7 @@ public class OntologyRegistryIRISource e
* @param ontologyManager
* @param loader
*/
- public OntologyRegistryIRISource(IRI registryIRI,
- OWLOntologyManager ontologyManager,
- RegistryLoader loader) {
+ public RegistryIRISource(IRI registryIRI, OWLOntologyManager ontologyManager, RegistryLoader loader) {
this(registryIRI, ontologyManager, loader, null);
}
@@ -62,10 +60,10 @@ public class OntologyRegistryIRISource e
*
* @param registryIRI
*/
- public OntologyRegistryIRISource(IRI registryIRI,
- OWLOntologyManager ontologyManager,
- RegistryLoader loader,
- OntologyInputSource parentSrc) {
+ public RegistryIRISource(IRI registryIRI,
+ OWLOntologyManager ontologyManager,
+ RegistryLoader loader,
+ OntologyInputSource parentSrc) {
this.registryIRI = registryIRI;
@@ -73,23 +71,23 @@ public class OntologyRegistryIRISource e
bindPhysicalIri(null);
Set<OWLOntology> subtrees = new HashSet<OWLOntology>();
- Registry reg = loader.loadRegistry(registryIRI,ontologyManager);
- // for (Registry reg : loader.loadRegistriesEager(registryIRI)) {
- for (RegistryItem ri : reg.getChildren()) {
- if (ri.isLibrary()) try {
- Set<OWLOntology> adds = loader.gatherOntologies(ri, ontologyManager, true);
- subtrees.addAll(adds);
- } catch (OWLOntologyAlreadyExistsException e) {
- // Chettefreca
- continue;
- } catch (OWLOntologyCreationException e) {
- log.warn("Failed to load ontology library " + ri.getName() + ". Skipping.", e);
- // If we can't load this library at all, scrap it.
- // TODO : not entirely convinced of this step.
- continue;
- }
+ Registry reg = loader.loadRegistry(registryIRI, ontologyManager);
+ // for (Registry reg : loader.loadRegistriesEager(registryIRI)) {
+ for (RegistryItem ri : reg.getChildren()) {
+ if (ri.isLibrary()) try {
+ Set<OWLOntology> adds = loader.gatherOntologies(ri, ontologyManager, true);
+ subtrees.addAll(adds);
+ } catch (OWLOntologyAlreadyExistsException e) {
+ // Chettefreca
+ continue;
+ } catch (OWLOntologyCreationException e) {
+ log.warn("Failed to load ontology library " + ri.getName() + ". Skipping.", e);
+ // If we can't load this library at all, scrap it.
+ // TODO : not entirely convinced of this step.
+ continue;
}
-// }
+ }
+ // }
// We always construct a new root now, even if there's just one subtree.
// Set<OWLOntology> subtrees = mgr.getOntologies();
@@ -105,11 +103,11 @@ public class OntologyRegistryIRISource e
}
}
- public OntologyRegistryIRISource(IRI registryIRI, RegistryLoader loader) {
+ public RegistryIRISource(IRI registryIRI, RegistryLoader loader) {
this(registryIRI, OWLManager.createOWLOntologyManager(), loader, null);
}
- public OntologyRegistryIRISource(IRI registryIRI, RegistryLoader loader, OntologyInputSource parentSrc) {
+ public RegistryIRISource(IRI registryIRI, RegistryLoader loader, OntologyInputSource parentSrc) {
this(registryIRI, OWLManager.createOWLOntologyManager(), loader, parentSrc);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Library.java Fri Jul 22 18:37:10 2011
@@ -22,22 +22,47 @@ import org.apache.stanbol.ontologymanage
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;
+/**
+ * An ontology library references one or more ontologies.
+ */
public interface Library extends RegistryItem {
+ /**
+ * The type of this registry item is {@link Type#LIBRARY}.
+ */
final Type type = Type.LIBRARY;
/**
+ * Returns the OWL ontologies that have been loaded in this library, if any, otherwise an exception is
+ * thrown.<br/>
+ * <br/>
* Upon invocation, this method immediately fires a registry content request event on itself. Note,
* however, that this method is in general not synchronized. Therefore, any listeners that react by
- * invoking a load method may or may not cause the content to be available to this method.
+ * invoking a load method may or may not cause the content to be available to this method before it
+ * returns.
*
- * @return
+ * @return the set of loaded OWL ontologies.
* @throws RegistryContentException
+ * if the requested ontologies have not been loaded.
*/
Set<OWLOntology> getOntologies() throws RegistryContentException;
+ /**
+ * Determines if the contents of this library have been loaded and are up-to-date.
+ *
+ * @return true if the contents are loaded and up-to-date, false otherwise.
+ */
boolean isLoaded();
+ /**
+ * Causes all the ontologies referenced by this library to be loaded, so that when
+ * {@link RegistryOntology#asOWLOntology()} is invoked on one of its children, it will return the
+ * corresponding OWL ontology, if a valid one was parsed from its location.
+ *
+ * @param mgr
+ * the OWL ontology manager to use for loading the ontologies in the library. It must not be
+ * null, lest an {@link IllegalArgumentException} be thrown.
+ */
void loadOntologies(OWLOntologyManager mgr);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java Fri Jul 22 18:37:10 2011
@@ -16,6 +16,7 @@
*/
package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem.Type;
import org.semanticweb.owlapi.model.OWLOntologyManager;
/**
@@ -23,17 +24,24 @@ import org.semanticweb.owlapi.model.OWLO
*/
public interface Registry extends RegistryItem {
+ /**
+ * The type of this registry item is {@link Type#REGISTRY}.
+ */
final Type type = Type.REGISTRY;
/**
+ * Returns the OWL ontology manager that this registry is using as a cache of its ontologies.
*
- * @return
+ * @return the ontology manager that is used as a cache.
*/
OWLOntologyManager getCache();
/**
+ * Sets the OWL ontology manager that this registry will use as a cache of its ontologies. If null, if
+ * will create its own.
*
* @param cache
+ * the ontology manager to be used as a cache.
*/
void setCache(OWLOntologyManager cache);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java Fri Jul 22 18:37:10 2011
@@ -16,62 +16,226 @@
*/
package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
-import java.net.URISyntaxException;
-import java.net.URL;
import java.util.Set;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentListener;
+import org.semanticweb.owlapi.model.IRI;
+/**
+ * A member of an ontology registry, possibly even the registry itself.
+ */
public interface RegistryItem {
/**
* The allowed types of registry item that a registry manager can handle.
*/
public enum Type {
+ /**
+ * An ontology library. Contains ontologies, is contained by ontology registries.
+ */
LIBRARY,
+ /**
+ * An ontology. Contained by libraries.
+ */
ONTOLOGY,
+ /**
+ * An ontology registry. Contains ontology libraries.
+ */
REGISTRY;
}
+ /**
+ * Sets a registry item as a child of this registry item. Also sets itself as a parent of the supplied
+ * item. Note that cycles are not allowed.
+ *
+ * @param child
+ * the registry item to be added as a child.
+ * @throws RegistryContentException
+ * if a cycle is detected or one of the registry items is invalid.
+ */
void addChild(RegistryItem child) throws RegistryContentException;
- void addContainer(RegistryItem container) throws RegistryContentException;
+ /**
+ * Sets a registry item as a parent of this registry item. Also sets itself as a child of the supplied
+ * item. Note that cycles are not allowed.
+ *
+ * @param parent
+ * the registry item to be added as a parent.
+ * @throws RegistryContentException
+ * if a cycle is detected or one of the registry items is invalid.
+ */
+ void addParent(RegistryItem parent) throws RegistryContentException;
+ /**
+ * Adds the supplied listener to the set of registry content listeners. If the listener is already
+ * registered with this registry item, this method has no effect.
+ *
+ * @param listener
+ * the listener to be added.
+ */
void addRegistryContentListener(RegistryContentListener listener);
+ /**
+ * Removes all children from this item. Also remove this item from the parents of all its former children.
+ */
void clearChildren();
+ /**
+ * Removes all parents from this item. Also remove this item from the children of all its former parents.
+ */
+ void clearParents();
+
+ /**
+ * Clears the set of registry content listeners.
+ */
void clearRegistryContentListeners();
+ /**
+ * Returns the child items of this registry item that has the supplied it if present. Note that this
+ * method will return null if an item with this id does not exist, or exists but is not registered as a
+ * child of this item, even if it is registered as its parent.
+ *
+ * @return the child item, or null if not present or not a child.
+ */
+ RegistryItem getChild(IRI id);
+
+ /**
+ * Returns the child items of this registry item if present.
+ *
+ * @return the child items, or an empty array if there are none.
+ */
RegistryItem[] getChildren();
- RegistryItem[] getContainers();
+ /**
+ * Returns the unique identifier of this registry item. In some cases, such as for ontologies, this also
+ * denotes their physical locations.
+ *
+ * @return the identifier of this registry item.
+ */
+ IRI getIRI();
+ /**
+ * Returns the short name of this registry item. It may or may not be a suffix of its ID.
+ *
+ * @return the short name of this registry item.
+ */
String getName();
+ /**
+ * Returns the parent items of this registry item that has the supplied it if present. Note that this
+ * method will return null if an item with this id does not exist, or exists but is not registered as a
+ * parent of this item, even if it is registered as its child.
+ *
+ * @return the parent item, or null if not present or not a parent.
+ */
+ RegistryItem getParent(IRI id);
+
+ /**
+ * Returns the parent items of this registry item if present.
+ *
+ * @return the parent items, or an empty array if there are none.
+ */
+ RegistryItem[] getParents();
+
+ /**
+ * Clears the set of objects to be notified any changes to this registry item.
+ *
+ * @return the set of registry content listeners registered with this item.
+ */
Set<RegistryContentListener> getRegistryContentListeners();
+ /**
+ * Returns the type of this registry item.
+ *
+ * @return the type of this registry item.
+ */
Type getType();
- URL getURL();
-
+ /**
+ * Determines if this registry item has any child items. It is a shortcut to {@link #getChildren()}
+ * <code>.isEmpty()</code>.
+ *
+ * @return true if this registry item has children, false otherwise.
+ */
boolean hasChildren();
+ /**
+ * Determines if this registry item has any parent items. It is a shortcut to {@link #getParents()}
+ * <code>.isEmpty()</code>.
+ *
+ * @return true if this registry item has parents, false otherwise.
+ */
+ boolean hasParents();
+
+ /**
+ * Determines if this registry item is a library.
+ *
+ * @return
+ * @deprecated This method will be removed to make room for possible extensions of the registry metamodel.
+ * Use {@link #getType()} or <code>instanceof</code> instead, and check for
+ * {@link Type#LIBRARY}.
+ */
boolean isLibrary();
+ /**
+ * Determines if this registry item is an ontology.
+ *
+ * @return
+ * @deprecated This method will be removed to make room for possible extensions of the registry metamodel.
+ * Use {@link #getType()} or <code>instanceof</code> instead, and check for
+ * {@link Type#ONTOLOGY}.
+ */
boolean isOntology();
+ /**
+ * Releases all the parent and child references of this item. If no objects other than the former parents
+ * and children are referencing it, this object is left stranded for garbage collection.
+ */
+ void prune();
+
+ /**
+ * Removes a registry item from the children of this registry item. Also removes itself from the parents
+ * of the supplied item. Note that cycles will result in no effect.
+ *
+ * @param child
+ * the child registry item to be removed.
+ */
void removeChild(RegistryItem child);
- void removeContainer(RegistryItem container);
+ /**
+ * Removes a registry item from the parents of this registry item. Also removes itself from the children
+ * of the supplied item. Note that cycles will result in no effect.
+ *
+ * @param parent
+ * the parent registry item to be removed.
+ */
+ void removeParent(RegistryItem parent);
+ /**
+ * Removes the supplied listener from the set of registry content listeners. If the listener was not
+ * previously registered with this registry item, this method has no effect.
+ *
+ * @param listener
+ * the listener to be removed.
+ */
void removeRegistryContentListener(RegistryContentListener listener);
- void setName(String string);
-
- void setURL(URL url) throws URISyntaxException;
+ /**
+ * Sets the unique identifier of this registry item.
+ *
+ * @param iri
+ * the identifier of this registry item.
+ * @deprecated This method is set for removal, as the unique identifier should not be set after creation.
+ */
+ void setIRI(IRI iri);
- String toString();
+ /**
+ * Sets the name of this registry item.
+ *
+ * @param name
+ * the name of this registry item.
+ */
+ void setName(String name);
}
\ No newline at end of file
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java Fri Jul 22 18:37:10 2011
@@ -16,14 +16,51 @@
*/
package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryOntologyNotLoadedException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem.Type;
import org.semanticweb.owlapi.model.OWLOntology;
+/**
+ * A special registry item that denotes an ontology referenced by a library.<br/>
+ * <br/>
+ * Note that this is <b>not equivalent</b> to an {@link OWLOntology}, since a {@link RegistryOntology} can
+ * exist regardless of the corresponding OWL ontology being loaded. For this reason, a registry ontology
+ * responds to {@link #getIRI()} with is stated <i>physical location</i>, even if it were found to differ from
+ * the ontology ID once the corresponding OWL ontology is loaded.<br/>
+ * <br/>
+ * Once the corresponding ontology has been loaded (e.g. by a call to
+ * {@link Library#loadOntologies(OWLOntologyManager)}), the corresponding {@link OWLOntology} object is
+ * available via calls to {@link #asOWLOntology()}.
+ */
public interface RegistryOntology extends RegistryItem {
+ /**
+ * The type of this registry item is {@link Type#ONTOLOGY}.
+ */
final Type type = Type.ONTOLOGY;
-
- OWLOntology asOWLOntology();
-
+
+ /**
+ * Returns the {@link OWLOntology} object corresponding to this registry ontology. If the ontology was not
+ * loaded, a {@link RegistryOntologyNotLoadedException} will be thrown.<br/>
+ * <br/>
+ * Upon invocation, this method immediately fires a registry content request event on itself. Note,
+ * however, that this method is in general not synchronized. Therefore, any listeners that react by
+ * invoking a load method may or may not cause the content to be available to this method before it
+ * returns.
+ *
+ * @return the OWL ontology corresponding to this registry ontology.
+ * @throws RegistryOntologyNotLoadedException
+ * if the ontology is not loaded.
+ */
+ OWLOntology asOWLOntology() throws RegistryOntologyNotLoadedException;
+
+ /**
+ * Returns the {@link OWLOntology} object corresponding to this registry ontology. Note that the method
+ * does not check whether the registry item ID matches the ontology ID or its physical location.
+ *
+ * @param owl
+ * the OWL ontology corresponding to this registry ontology.
+ */
void setOWLOntology(OWLOntology owl);
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java Fri Jul 22 18:37:10 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.impl;
import org.osgi.framework.BundleActivator;
@@ -23,29 +23,23 @@ import org.slf4j.LoggerFactory;
/**
* Called upon OSGi bundle startup and shutdown, it constructs and releases the resources required by the KReS
- * Ontology Network Manager during its activity.
- *
- * @author alessandro
- *
+ * Ontology Network Manager during its activity. Should only do OSGi stuff.
*/
public class Activator implements BundleActivator {
+ private Logger log = LoggerFactory.getLogger(getClass());
+
@Override
public void start(BundleContext context) throws Exception {
-
+ log.debug("Instantiating ONM static context...");
// context.getBundle().getLocation();
// Instantiate the static context for the KReS ONM
-
- Logger log = LoggerFactory.getLogger(this.getClass());
- log.debug("KReS :: Instantiating ONM static context...");
-
- log.info("KReS :: Ontology Network Manager set up.");
-
+ log.info("Ontology Network Manager set up.");
}
@Override
public void stop(BundleContext context) throws Exception {
- LoggerFactory.getLogger(this.getClass()).info("KReS :: Ontology Network Manager brought down.");
+ log.info("Ontology Network Manager brought down.");
}
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryItemFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryItemFactoryImpl.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryItemFactoryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryItemFactoryImpl.java Fri Jul 22 18:37:10 2011
@@ -16,9 +16,6 @@
*/
package org.apache.stanbol.ontologymanager.ontonet.impl.registry;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-
import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryItemFactory;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
@@ -26,82 +23,33 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.model.LibraryImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.model.RegistryImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.model.RegistryOntologyImpl;
-import org.apache.stanbol.ontologymanager.ontonet.xd.vocabulary.CODOVocabulary;
-import org.semanticweb.owlapi.apibinding.OWLManager;
-import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLClass;
-import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
-import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLOntology;
+/**
+ * Default implementation of a registry item factory.
+ */
public class RegistryItemFactoryImpl implements RegistryItemFactory {
- public static final String REGISTRY_LIBRARY_ID = CODOVocabulary.CODD_OntologyLibrary;
-
- public static final String IS_PART_OF_ID = CODOVocabulary.PARTOF_IsPartOf;
-
- public static final String IS_ONTOLOGY_OF_ID = CODOVocabulary.ODPM_IsOntologyOf;
-
- private final OWLClass cRegistryLibrary;
-
- private final OWLObjectProperty isPartOf, isOntologyOf;
-
- public RegistryItemFactoryImpl() {
- OWLDataFactory df = OWLManager.getOWLDataFactory();
- cRegistryLibrary = df.getOWLClass(IRI.create(REGISTRY_LIBRARY_ID));
- isPartOf = df.getOWLObjectProperty(IRI.create(IS_PART_OF_ID));
- isOntologyOf = df.getOWLObjectProperty(IRI.create(IS_ONTOLOGY_OF_ID));
- }
+ /**
+ * Creates a new instance of {@link RegistryItemFactoryImpl}.
+ */
+ public RegistryItemFactoryImpl() {}
@Override
public Library createLibrary(OWLNamedIndividual ind) {
- // if (!ind.getTypes(ontologies).contains(cRegistryLibrary)) throw new IllegalArgumentException(
- // "Will not create a library from an individual not stated to be of type "
- // + REGISTRY_LIBRARY_ID + " in the supplied ontologies.");
- Library l = null;
- try {
- l = new LibraryImpl(ind.getIRI().getFragment(), ind.getIRI().toURI().toURL());
- // // recurse into its children
- // for (OWLOntology o : ontologies) {
- // for (OWLAxiom ax : ind.getReferencingAxioms(o, true)) {
- // if (ax.isOfType(AxiomType.OBJECT_PROPERTY_ASSERTION)
- // && (isOntologyOf.equals(((OWLObjectPropertyAssertionAxiom) ax).getProperty()) || isPartOf
- // .equals(((OWLObjectPropertyAssertionAxiom) ax).getProperty()))) {
- //
- // }
- // }
- // }
-
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException(e);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(e);
- }
- return l;
+ return new LibraryImpl(ind.getIRI(), ind.getIRI().getFragment());
}
@Override
public Registry createRegistry(OWLOntology o) {
- try {
- return new RegistryImpl(o.getOntologyID().toString(), o.isAnonymous() ? null : o.getOntologyID()
- .getOntologyIRI().toURI().toURL());
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException(e);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(e);
- }
+ return o.isAnonymous() ? null : new RegistryImpl(o.getOntologyID().getOntologyIRI(), o
+ .getOntologyID().toString());
}
@Override
public RegistryOntology createRegistryOntology(OWLNamedIndividual ind) {
- try {
- return new RegistryOntologyImpl(ind.getIRI().getFragment(), ind.getIRI().toURI().toURL());
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException(e);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(e);
- }
+ return new RegistryOntologyImpl(ind.getIRI(), ind.getIRI().getFragment());
}
}
Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java?rev=1149687&r1=1149686&r2=1149687&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/registry/RegistryLoaderImpl.java Fri Jul 22 18:37:10 2011
@@ -17,12 +17,10 @@
package org.apache.stanbol.ontologymanager.ontonet.impl.registry;
import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -33,14 +31,12 @@ import java.util.Set;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryContentException;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryLoader;
-import org.apache.stanbol.ontologymanager.ontonet.api.registry.RegistryManager;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Library;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OWLOntologyManagerFactoryImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.ODPRegistryCacheException;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.ODPRegistryCacheManager;
-import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.RegistryUtils;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.cache.URIUnresolvableException;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.model.AbstractRegistryItem;
import org.apache.stanbol.ontologymanager.ontonet.impl.registry.model.LibraryImpl;
@@ -161,7 +157,7 @@ public class RegistryLoaderImpl implemen
} else if (registryItem.isOntology()) {
IRI locationIri = null;
try {
- locationIri = IRI.create(((RegistryOntologyImpl) registryItem).getURL());
+ locationIri = ((RegistryOntologyImpl) registryItem).getIRI();
result.add(manager.loadOntology(locationIri));
} catch (OWLOntologyAlreadyExistsException ex) {
// We are trying to oad an already existing ontology,
@@ -170,8 +166,6 @@ public class RegistryLoaderImpl implemen
} catch (OWLOntologyCreationIOException ex) {
log.error("Cannot load ontology from " + locationIri);
- } catch (URISyntaxException e) {
- log.warn("Malformed URI for ontology " + registryItem.getName() + ". Skipping.", e);
}
} else if (registryItem.isLibrary()) {
for (RegistryItem item : ((LibraryImpl) registryItem).getChildren()) {
@@ -188,8 +182,8 @@ public class RegistryLoaderImpl implemen
public Library getLibrary(Registry reg, IRI libraryID) {
for (RegistryItem child : reg.getChildren()) {
try {
- if (child.isLibrary() && IRI.create(child.getURL()).equals(libraryID)) return (LibraryImpl) child;
- } catch (URISyntaxException e) {
+ if (child.isLibrary() && child.getIRI().equals(libraryID)) return (LibraryImpl) child;
+ } catch (Exception e) {
// If some URL is not well-formed here and there, sticazzi
continue;
}
@@ -197,7 +191,7 @@ public class RegistryLoaderImpl implemen
return null;
}
- private OWLOntology getMergedOntology(URL registryLocation) throws RegistryContentException {
+ private OWLOntology getMergedOntology(IRI registryLocation) throws RegistryContentException {
OWLOntology ontology = null;
try {
@@ -258,8 +252,6 @@ public class RegistryLoaderImpl implemen
throw new RegistryContentException(e);
} catch (UnsupportedEncodingException e) {
throw new RegistryContentException(e);
- } catch (URISyntaxException e) {
- throw new RegistryContentException(e);
}
return ontology;
}
@@ -279,7 +271,7 @@ public class RegistryLoaderImpl implemen
public Object getParent(Object child) {
if (child instanceof AbstractRegistryItem) {
- return ((RegistryItem) child).getContainers();
+ return ((RegistryItem) child).getParents();
}
return null;
}
@@ -304,16 +296,15 @@ public class RegistryLoaderImpl implemen
String registryLocation = ""/*
* URLListEditor .parseNameValueString(regs[i])[1]
*/;
- registry1 = new RegistryImpl(registryName);
- registry1.setURL(new URL(registryLocation));
+ registry1 = new RegistryImpl(IRI.create(registryLocation), registryName);
} catch (Exception e) {
if (registry1 != null) {
registry1.setError(e.getLocalizedMessage());
- log.error("KReS :: Error on ODP registry: " + registry1.getName(), e);
+ log.error("Error on ODP registry: " + registry1.getName(), e);
}
}
if (registry1 != null) registries.add(registry1);
- else log.error("KReS :: Cannot load ODP registry: " + regs[i]);
+ else log.error("Cannot load ODP registry: " + regs[i]);
}
return registries;
}
@@ -335,27 +326,22 @@ public class RegistryLoaderImpl implemen
private Library getTree(OWLNamedIndividual i, OWLOntology ontology) {
- Library to = new LibraryImpl(new RDFSLabelGetter(ontology, i.getIRI(), false).getPreferred());
+ Library to = new LibraryImpl(i.getIRI(),
+ new RDFSLabelGetter(ontology, i.getIRI(), false).getPreferred());
try {
Set<OWLNamedIndividual> children = getParts(i, ontology);
if (children.size() == 0) return to;
for (OWLNamedIndividual childIndividual : children) {
if (isLibrary(childIndividual, ontology)) {
Library t = this.getTree(childIndividual, ontology);
- t.setURL(childIndividual.getIRI().toURI().toURL());
+ t.setIRI(childIndividual.getIRI());
to.addChild(t);
} else if (isOntology(childIndividual, ontology)) {
- RegistryOntologyImpl t = new RegistryOntologyImpl(new RDFSLabelGetter(ontology,
- childIndividual.getIRI(), false).getPreferred());
- t.setURL(childIndividual.getIRI().toURI().toURL());
+ RegistryOntologyImpl t = new RegistryOntologyImpl(childIndividual.getIRI(),
+ new RDFSLabelGetter(ontology, childIndividual.getIRI(), false).getPreferred());
to.addChild(t);
}
}
- } catch (MalformedURLException e) {
- log.error("MalformedURLException caught while getting tree for " + i.getIRI(), e);
-
- } catch (URISyntaxException e) {
- log.error("URISyntaxException caught while getting tree for " + i.getIRI(), e);
} catch (RegistryContentException e) {
log.error("RegistryContentException caught while getting tree for " + i.getIRI(), e);
}
@@ -370,8 +356,8 @@ public class RegistryLoaderImpl implemen
public boolean hasLibrary(Registry reg, IRI libraryID) {
for (RegistryItem child : reg.getChildren()) {
try {
- if (child.isLibrary() && IRI.create(child.getURL()).equals(libraryID)) return true;
- } catch (URISyntaxException e) {
+ if (child.isLibrary() && child.getIRI().equals(libraryID)) return true;
+ } catch (Exception e) {
// If some URL is not well-formed here and there, sticazzi
continue;
}
@@ -392,13 +378,14 @@ public class RegistryLoaderImpl implemen
}
@Override
- public Registry loadLibraryEager(IRI registryPhysicalIRI, IRI libraryID) {
+ public Registry loadLibrary(IRI registryPhysicalIRI, IRI libraryID) {
// FIXME! linbraryID unused
Registry registry = null;
OWLOntologyManager mgr = onm.getOwlCacheManager();
try {
OWLOntology ontology = mgr.loadOntology(registryPhysicalIRI);
- registry = onm.getRegistryManager().populateRegistry(ontology);
+ registry = onm.getRegistryManager().createModel(Collections.singleton(ontology)).iterator()
+ .next();
} catch (OWLOntologyDocumentAlreadyExistsException e) {
log.warn("Ontology document at " + e.getOntologyDocumentIRI()
+ " exists and will not be reloaded.", e);
@@ -407,8 +394,6 @@ public class RegistryLoaderImpl implemen
// Do nothing. Existing ontologies are fine.
} catch (OWLOntologyCreationException e) {
log.error("Could not load ontology " + registryPhysicalIRI + " .", e);
- } catch (RegistryContentException e) {
- log.error("Could not populate registry " + registryPhysicalIRI + " .", e);
} finally {}
return registry;
}
@@ -473,17 +458,17 @@ public class RegistryLoaderImpl implemen
for (Registry current : registries) {
c++;
log.debug("Loading " + current.toString() + " [" + c + "/" + regsize + "]");
- if (!ODPRegistryCacheManager.registryContains(current.getURL().toURI())) {
+ if (!ODPRegistryCacheManager.registryContains(current.getIRI().toURI())) {
try {
- log.debug("Fetching: " + current.getURL().toURI());
- registryOntologiesCache.put(current.getURL().toURI(),
- ODPRegistryCacheManager.getOntology(current.getURL().toURI()));
+ log.debug("Fetching: " + current.getIRI().toURI());
+ registryOntologiesCache.put(current.getIRI().toURI(),
+ ODPRegistryCacheManager.getOntology(current.getIRI().toURI()));
} catch (URIUnresolvableException e) {
- log.error("KReS :: could not resolve URI " + current.getURL().toURI(), e);
- registryOntologiesCache.put(current.getURL().toURI(), null);
+ log.error("KReS :: could not resolve URI " + current.getIRI().toURI(), e);
+ registryOntologiesCache.put(current.getIRI().toURI(), null);
} catch (ODPRegistryCacheException e) {
- log.error("KReS :: failed to cache ontology " + current.getURL().toURI(), e);
- registryOntologiesCache.put(current.getURL().toURI(), null);
+ log.error("KReS :: failed to cache ontology " + current.getIRI().toURI(), e);
+ registryOntologiesCache.put(current.getIRI().toURI(), null);
}
}
}
@@ -494,7 +479,7 @@ public class RegistryLoaderImpl implemen
registry = setupRegistry(registry);
} catch (RegistryContentException e) {
((RegistryImpl) registry).setError(" [Unable to load from location "
- + registry.getURL().toString() + "]");
+ + registry.getIRI().toString() + "]");
}
}
} catch (Throwable th) {
@@ -509,7 +494,9 @@ public class RegistryLoaderImpl implemen
if (mgr == null) mgr = onm.getOwlCacheManager();
try {
OWLOntology ontology = mgr.loadOntology(registryPhysicalIRI);
- registry = onm.getRegistryManager().populateRegistry(ontology);
+ // registry = onm.getRegistryManager().populateRegistry(ontology);
+ registry = onm.getRegistryManager().createModel(Collections.singleton(ontology)).iterator()
+ .next();
} catch (OWLOntologyDocumentAlreadyExistsException e) {
log.warn("Ontology document at " + e.getOntologyDocumentIRI()
+ " exists and will not be reloaded.", e);
@@ -518,8 +505,6 @@ public class RegistryLoaderImpl implemen
// Do nothing. Existing ontologies are fine.
} catch (OWLOntologyCreationException e) {
log.error("Could not load ontology " + registryPhysicalIRI + " .", e);
- } catch (RegistryContentException e) {
- log.error("Could not populate registry " + registryPhysicalIRI + " .", e);
} finally {}
return registry;
}
@@ -594,7 +579,7 @@ public class RegistryLoaderImpl implemen
// For each registry:
registry.clearChildren();
- OWLOntology ontology = getMergedOntology(registry.getURL());
+ OWLOntology ontology = getMergedOntology(registry.getIRI());
// TODO: Restore ODP cache manager.
// setManager(ODPRegistryCacheManager.getManager());