Author: alexdma
Date: Tue Jun 28 17:33:05 2011
New Revision: 1140743
URL: http://svn.apache.org/viewvc?rev=1140743&view=rev
Log:
STANBOL-178 :
- Added more javadoc and metatypes for ontonet offline features
Modified:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/OSGI-INF/metatype/metatype.properties
Modified:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java?rev=1140743&r1=1140742&r2=1140743&view=diff
==============================================================================
---
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
(original)
+++
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
Tue Jun 28 17:33:05 2011
@@ -11,8 +11,8 @@ import org.semanticweb.owlapi.util.AutoI
/**
* An {@link OntologyInputSource} that recursively tries to hijack all import
declarations to the directory
- * containing the input ontology (i.e. the parent of the file itself). It can
be used for offline ontology
- * loading, if one has the entire imports closure available in single
directory.<br>
+ * containing the input ontology (i.e. to the parent directory of the file
itself). It can be used for offline
+ * ontology loading, if one has the entire imports closure available in single
directory.<br>
* <br>
* The behaviour of this class is inherited from the {@link AutoIRIMapper} in
the OWL API, and so are its
* limitations and fallback policies.
@@ -22,21 +22,41 @@ import org.semanticweb.owlapi.util.AutoI
*/
public class ParentPathInputSource extends AbstractOntologyInputSource {
+ /**
+ * Creates a new parent path ontology input source. When created using
this constructor, the only active
+ * IRI mapper will be the one that maps to any ontology found in the
parent directory of the supplied
+ * file.
+ *
+ * @param rootFile
+ * the root ontology file. Must not be a directory.
+ * @throws OWLOntologyCreationException
+ * if <code>rootFile</code> does not exist, is not an ontology
or one of its imports failed to
+ * load.
+ */
public ParentPathInputSource(File rootFile) throws
OWLOntologyCreationException {
this(rootFile, OWLManager.createOWLOntologyManager());
}
/**
- * If the developer wishes to recycle an {@link OWLOntologyManager}, they
can do so by passing it to the
- * method. Please note that recycling ontology managers will increase the
likelihood of
- * {@link OWLOntologyAlreadyExistsException}s being thrown.
+ * Creates a new parent path ontology input source. If the developer
wishes to recycle an
+ * {@link OWLOntologyManager} (e.g. in order to keep the active IRI
mappers attached to it), they can do
+ * so by passing it to the method. Please note that recycling ontology
managers will increase the
+ * likelihood of {@link OWLOntologyAlreadyExistsException}s being thrown.
*
* @param rootFile
+ * the root ontology file. Must not be a directory.
* @param mgr
* the ontology manager to recycle. Note that an {@link
AutoIRIMapper} will be added to it.
* @throws OWLOntologyCreationException
+ * if <code>rootFile</code> does not exist, is not an ontology
or one of its imports failed to
+ * load.
*/
public ParentPathInputSource(File rootFile, OWLOntologyManager mgr) throws
OWLOntologyCreationException {
+
+ // Directories are not allowed
+ if (rootFile.isDirectory()) throw new IllegalArgumentException(
+ "Could not determine root ontology : file " + rootFile
+ + " is a directory. Only regular files are allowed.");
AutoIRIMapper mapper = new AutoIRIMapper(rootFile.getParentFile(),
true);
mgr.addIRIMapper(mapper);
rootOntology = mgr.loadOntologyFromOntologyDocument(rootFile);
Modified:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java?rev=1140743&r1=1140742&r2=1140743&view=diff
==============================================================================
---
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
(original)
+++
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
Tue Jun 28 17:33:05 2011
@@ -18,7 +18,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.ReferenceStrategy;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.stanboltools.offline.OfflineMode;
-import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManagerConfiguration;
import org.apache.stanbol.ontologymanager.ontonet.api.io.BlankOntologySource;
@@ -61,15 +60,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * The running context of a KReS Ontology Network Manager instance. From this
object it is possible to obtain
+ * The running context of a Stanbol Ontology Network Manager instance. From
this object it is possible to obtain
* factories, indices, registries and what have you.
*
* @author alessandro
+ * @see ONManager
*
*/
@Component(immediate = true, metatype = true)
@Service(ONManager.class)
-// @Property(name="service.ranking",intValue=5)
public class ONManagerImpl implements ONManager {
/**
@@ -82,41 +81,6 @@ public class ONManagerImpl implements ON
private class Helper {
/**
- * Adds the ontology from the given iri to the core space of the given
scope.
- *
- *
- * @param scopeID
- * @param locationIri
- */
- public synchronized void addToCoreSpace(String scopeID, String[]
locationIris) {
- OntologyScope scope =
getScopeRegistry().getScope(IRI.create(scopeID));
- OntologySpace corespc = scope.getCoreSpace();
- scope.tearDown();
- corespc.tearDown();
- for (String locationIri : locationIris) {
- try {
- corespc.addOntology(new
RootOntologyIRISource(IRI.create(locationIri)));
- //
- // corespc.addOntology(
- // createOntologyInputSource(locationIri));
- log.debug("Added " + locationIri + " to scope " + scopeID
+ " in the core space.", this);
- // OntologySpace cs = scope.getCustomSpace();
- // if (cs instanceof CustomOntologySpace) {
- // (
- //
(CustomOntologySpace)cs).attachCoreSpace((CoreOntologySpace)corespc,
- // false);
- // }
- } catch (UnmodifiableOntologySpaceException e) {
- log.error("Core space for scope " + scopeID + " denied
addition of ontology "
- + locationIri, e);
- } catch (OWLOntologyCreationException e) {
- log.error("Creation of ontology from source " +
locationIri + " failed.", e);
- }
- }
- corespc.setUp();
- }
-
- /**
* Adds the ontology fromt he given iri to the custom space of the
given scope
*
* @param scopeID
@@ -150,29 +114,6 @@ public class ONManagerImpl implements ON
}
}
- /**
- * Create an empty scope. The scope is created, registered and
activated
- *
- * @param scopeID
- * @return
- * @throws DuplicateIDException
- */
- public synchronized OntologyScope createScope(String scopeID) throws
DuplicateIDException {
- OntologyInputSource oisbase = new BlankOntologySource();
-
- IRI scopeIRI = IRI.create(scopeID);
-
- /*
- * The scope is created by the ScopeFactory or loaded to the scope
registry of KReS
- */
- OntologyScope scope;
- scope = ontologyScopeFactory.createOntologyScope(scopeIRI,
oisbase);
-
- scope.setUp();
- scopeRegistry.registerScope(scope, true);
- log.debug("Created scope " + scopeIRI, this);
- return scope;
- }
}
@Reference
@@ -212,7 +153,6 @@ public class ONManagerImpl implements ON
private SessionManager sessionManager;
private ClerezzaOntologyStorage storage;
- // private ClerezzaOntologyStorage storage;
@Reference
private TcManager tcm;
@@ -259,15 +199,20 @@ public class ONManagerImpl implements ON
* Constructor to be invoked by non-OSGi environments.
*
* @param tcm
+ * the triple collection manager to be used for storing
ontologies.
* @param wtcp
+ * the triple collection provider to be used for storing
ontologies.
+ * @param onmconfig
+ * the configuration of this ontology network manager.
* @param configuration
+ * additional parameters for the ONManager not included in
{@link ONManagerConfiguration}.
*/
public ONManagerImpl(TcManager tcm,
WeightedTcProvider wtcp,
ONManagerConfiguration onmconfig,
Dictionary<String,Object> configuration) {
this();
- // Assume this.tcm and this.wtcp were not filled in by OSGi-DS.
+ // Assume this.tcm this.wtcp and this.wtcp were not filled in by
OSGi-DS.
this.tcm = tcm;
this.wtcp = wtcp;
this.config = onmconfig;
Modified:
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/OSGI-INF/metatype/metatype.properties
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1140743&r1=1140742&r2=1140743&view=diff
==============================================================================
---
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++
incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/OSGI-INF/metatype/metatype.properties
Tue Jun 28 17:33:05 2011
@@ -1,4 +1,11 @@
#===============================================================================
+#Properties defined by the Ontology Network Manager
+#===============================================================================
+org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl.name = Apache
Stanbol Ontology Network Manager
+org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl.description = A
controlled environment for managing Web ontology networks.
+
+
+#===============================================================================
#Properties defined by the Ontology Network Manager configuration
#===============================================================================
org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerConfigurationImpl.name
= Apache Stanbol Ontology Network Manager configuration