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/11/02 19:41:39 UTC
svn commit: r1196752 [2/3] - in /incubator/stanbol/trunk:
explanation/core/src/test/java/org/apache/stanbol/explanation/impl/
ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/
ontologymanager/ontonet/src/mai...
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/CachingPolicy.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/CachingPolicy.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/CachingPolicy.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/CachingPolicy.java Wed Nov 2 18:41:36 2011
@@ -18,6 +18,8 @@ package org.apache.stanbol.ontologymanag
/**
* The possible policies a registry manager can adopt for distributed caching.
+ *
+ * @author alexdma
*/
public enum CachingPolicy {
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Library.java Wed Nov 2 18:41:36 2011
@@ -18,13 +18,15 @@ package org.apache.stanbol.ontologymanag
import java.util.Set;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryContentException;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
-import org.semanticweb.owlapi.model.OWLOntologyManager;
/**
* An ontology library references one or more ontologies.
+ *
+ * @author alexdma
*/
public interface Library extends RegistryItem {
@@ -38,7 +40,7 @@ public interface Library extends Registr
*
* @return the ontology manager that is used as a cache.
*/
- OWLOntologyManager getCache();
+ OntologyProvider<?> getCache();
/**
* Returns the OWL ontologies that have been loaded in this library, if any, otherwise an exception is
@@ -55,6 +57,16 @@ public interface Library extends Registr
*/
Set<OWLOntology> getOntologies() throws RegistryContentException;
+ OWLOntology getOntology(IRI id) throws RegistryContentException;
+
+ /**
+ * Returns a string that can be encoded as a IRI/URI/UriRef etc. for retrieving the raw ontology.
+ *
+ * @param ontologyId
+ * @return
+ */
+ String getOntologyReference(IRI ontologyId) throws RegistryContentException;
+
/**
* Determines if the contents of this library have been loaded and are up-to-date.
*
@@ -71,7 +83,7 @@ public interface Library extends Registr
* 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);
+ void loadOntologies(OntologyProvider<?> cache);
/**
* Sets the OWL ontology manager that this library will use as a cache of its ontologies. If null, if will
@@ -80,6 +92,6 @@ public interface Library extends Registr
* @param cache
* the ontology manager to be used as a cache.
*/
- void setCache(OWLOntologyManager cache);
+ void setCache(OntologyProvider<?> cache);
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Registry.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Registry.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Registry.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/Registry.java Wed Nov 2 18:41:36 2011
@@ -18,6 +18,8 @@ package org.apache.stanbol.ontologymanag
/**
* An ontology registry can reference zero or more ontology libraries.
+ *
+ * @author alexdma
*/
public interface Registry extends RegistryItem {
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryItem.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryItem.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryItem.java Wed Nov 2 18:41:36 2011
@@ -24,6 +24,8 @@ import org.semanticweb.owlapi.model.IRI;
/**
* A member of an ontology registry, possibly even the registry itself.
+ *
+ * @author alexdma
*/
public interface RegistryItem {
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryOntology.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryOntology.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryOntology.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/api/model/RegistryOntology.java Wed Nov 2 18:41:36 2011
@@ -18,10 +18,11 @@ package org.apache.stanbol.ontologymanag
import java.util.Map;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryOntologyNotLoadedException;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
-import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
/**
* A special registry item that denotes an ontology referenced by a library.<br/>
@@ -31,9 +32,10 @@ import org.semanticweb.owlapi.model.OWLO
* 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 #getRawOntology(IRI)}.
+ * Once the corresponding ontology has been loaded (e.g. by a call to {@link Library#loadOntologies(OntologyProvider)}),
+ * the corresponding {@link OWLOntology} object is available via calls to {@link #getRawOntology(IRI)}.
+ *
+ * @author alexdma
*/
public interface RegistryOntology extends RegistryItem {
@@ -42,7 +44,7 @@ public interface RegistryOntology extend
*/
final Type type = Type.ONTOLOGY;
- Map<IRI,OWLOntology> getRawOntologies() throws RegistryOntologyNotLoadedException;
+ Map<IRI,String> getReferenceMap() throws RegistryOntologyNotLoadedException;
/**
* Returns the {@link OWLOntology} object corresponding to this registry ontology. If the ontology was not
@@ -60,12 +62,48 @@ public interface RegistryOntology extend
* @throws RegistryOntologyNotLoadedException
* if the ontology is not loaded.
*/
+ String getReference(IRI libraryID) throws RegistryOntologyNotLoadedException;
+
+ /**
+ * 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.
+ *
+ * @deprecated this method will return null if the cache that stores the ontology content is not
+ * implemented as an OWLOntologyManager. Applications should either request the reference via
+ * a call to {@link #getReference(IRI)} and resolve it, or request the
+ * {@link OWLOntologyCreationException} from the library referencing this.
+ * @param libraryID
+ * TODO
+ *
+ * @return the OWL ontology corresponding to this registry ontology.
+ * @throws RegistryOntologyNotLoadedException
+ * if the ontology is not loaded.
+ */
OWLOntology getRawOntology(IRI libraryID) 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 libraryID TODO
+ *
+ * @param libraryID
+ * TODO
+ * @param owl
+ * the OWL ontology corresponding to this registry ontology.
+ */
+ void setReference(IRI libraryID, String reference);
+
+ /**
+ * 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.
+ *
+ * @deprecated if the cache is not implemented in OWLAPI, this will not be set.
+ * @param libraryID
+ * TODO
* @param owl
* the OWL ontology corresponding to this registry ontology.
*/
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryItemFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryItemFactoryImpl.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryItemFactoryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryItemFactoryImpl.java Wed Nov 2 18:41:36 2011
@@ -16,6 +16,7 @@
*/
package org.apache.stanbol.ontologymanager.registry.impl;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryItemFactory;
import org.apache.stanbol.ontologymanager.registry.api.model.Library;
import org.apache.stanbol.ontologymanager.registry.api.model.Registry;
@@ -28,17 +29,23 @@ import org.semanticweb.owlapi.model.OWLO
/**
* Default implementation of a registry item factory.
+ *
+ * @author alexdma
*/
public class RegistryItemFactoryImpl implements RegistryItemFactory {
+ private OntologyProvider<?> cache;
+
/**
* Creates a new instance of {@link RegistryItemFactoryImpl}.
*/
- public RegistryItemFactoryImpl() {}
+ public RegistryItemFactoryImpl(OntologyProvider<?> provider) {
+ this.cache = provider;
+ }
@Override
public Library createLibrary(OWLNamedIndividual ind) {
- return new LibraryImpl(ind.getIRI(), ind.getIRI().getFragment());
+ return new LibraryImpl(ind.getIRI(), ind.getIRI().getFragment(), cache);
}
@Override
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/RegistryManagerImpl.java Wed Nov 2 18:41:36 2011
@@ -25,6 +25,8 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -33,6 +35,8 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryContentException;
import org.apache.stanbol.ontologymanager.registry.api.RegistryContentListener;
import org.apache.stanbol.ontologymanager.registry.api.RegistryItemFactory;
@@ -71,6 +75,8 @@ import org.slf4j.LoggerFactory;
/**
* Default implementation of the registry manager, that listens to requests on its referenced resources and
* issues loading requests accordingly.
+ *
+ * @author alexdma
*/
@Component(immediate = true, metatype = true)
@Service(RegistryManager.class)
@@ -94,7 +100,8 @@ public class RegistryManagerImpl impleme
hasOntology = factory.getOWLObjectProperty(IRI.create(CODOVocabulary.ODPM_HasOntology));
}
- private OWLOntologyManager cache = null;
+ @Reference
+ private OntologyProvider<?> cache = null;
@Property(name = RegistryManager.CACHING_POLICY, options = {
@PropertyOption(value = '%'
@@ -136,18 +143,20 @@ public class RegistryManagerImpl impleme
* YOU NEED TO USE {@link #RegistryManagerImpl(Dictionary)} or its overloads, to parse the configuration
* and then initialise the rule store if running outside an OSGI environment.
*/
- public RegistryManagerImpl() {
- riFactory = new RegistryItemFactoryImpl();
- }
+ public RegistryManagerImpl() {}
/**
* To be invoked by non-OSGi environments.
*
- * @param configuration
+ * @param the
+ * configuration registry manager-specific configuration
*/
- public RegistryManagerImpl(OfflineConfiguration offline, Dictionary<String,Object> configuration) {
+ public RegistryManagerImpl(OfflineConfiguration offline,
+ OntologyProvider<?> cache,
+ Dictionary<String,Object> configuration) {
this();
this.offline = offline;
+ this.cache = cache;
activate(configuration);
}
@@ -206,24 +215,32 @@ public class RegistryManagerImpl impleme
}
}
- // Build the model.
- createModel(regOnts);
-
// Create and set the cache.
if (cachingPolicyString.equals(CachingPolicy.CENTRALISED.name())) {
- this.cache = OWLOntologyManagerFactory.createOWLOntologyManager(offlineResources);
+ // this.cache = OWLOntologyManagerFactory.createOWLOntologyManager(offlineResources);
+ if (cache == null) {
+ log.warn("Caching policy is set as Centralised, but no ontology provider is supplied. Will use new in-memory tcProvider.");
+ cache = new ClerezzaOntologyProvider(TcManager.getInstance(), offline, Parser.getInstance());
+ }
+ // else sta bene cosi'
} else if (cachingPolicyString.equals(CachingPolicy.DISTRIBUTED.name())) {
this.cache = null;
}
+ riFactory = new RegistryItemFactoryImpl(cache);
+
+ // Build the model.
+ createModel(regOnts);
+
+ // Set the cache on libraries.
Set<RegistryItem> visited = new HashSet<RegistryItem>();
for (Registry reg : getRegistries())
for (RegistryItem child : reg.getChildren())
if (!visited.contains(child)) {
if (child instanceof Library) {
if (this.cache != null) ((Library) child).setCache(this.cache);
- else ((Library) child).setCache(OWLOntologyManagerFactory
- .createOWLOntologyManager(offlineResources));
+ else ((Library) child).setCache(new ClerezzaOntologyProvider(TcManager.getInstance(),
+ offline, Parser.getInstance()));
}
visited.add(child);
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/AbstractRegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/AbstractRegistryItem.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/AbstractRegistryItem.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/AbstractRegistryItem.java Wed Nov 2 18:41:36 2011
@@ -28,6 +28,12 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem;
import org.semanticweb.owlapi.model.IRI;
+/**
+ * Abstract default implementation of registry items.
+ *
+ * @author alexdma
+ *
+ */
public abstract class AbstractRegistryItem implements RegistryItem {
/* Two-way adjacency index TODO use maps instead? */
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/LibraryImpl.java Wed Nov 2 18:41:36 2011
@@ -16,16 +16,34 @@
*/
package org.apache.stanbol.ontologymanager.registry.impl.model;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLConnection;
import java.util.HashSet;
import java.util.Set;
+import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.EntityAlreadyExistsException;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.access.TcProvider;
+import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
+import org.apache.stanbol.ontologymanager.registry.api.IllegalRegistryCycleException;
import org.apache.stanbol.ontologymanager.registry.api.LibraryContentNotLoadedException;
import org.apache.stanbol.ontologymanager.registry.api.RegistryContentException;
import org.apache.stanbol.ontologymanager.registry.api.RegistryOntologyNotLoadedException;
+import org.apache.stanbol.ontologymanager.registry.api.RegistryOperation;
import org.apache.stanbol.ontologymanager.registry.api.model.Library;
+import org.apache.stanbol.ontologymanager.registry.api.model.Registry;
import org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem;
import org.apache.stanbol.ontologymanager.registry.api.model.RegistryOntology;
-import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.apache.stanbol.owl.transformation.OWLAPIToClerezzaConverter;
import org.semanticweb.owlapi.io.OWLOntologyCreationIOException;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
@@ -42,7 +60,7 @@ import org.slf4j.LoggerFactory;
*/
public class LibraryImpl extends AbstractRegistryItem implements Library {
- private OWLOntologyManager cache;
+ private OntologyProvider<?> cache;
private boolean loaded = false;
@@ -53,20 +71,10 @@ public class LibraryImpl extends Abstrac
*
* @param iri
* the library identifier and possible physical location.
- */
- public LibraryImpl(IRI iri) {
- this(iri, OWLManager.createOWLOntologyManager());
- }
-
- /**
- * Creates a new instance of {@link LibraryImpl}.
- *
- * @param iri
- * the library identifier and possible physical location.
* @param cache
* the {@link OWLOntologyManager} to be used for caching ontologies in-memory.
*/
- public LibraryImpl(IRI iri, OWLOntologyManager cache) {
+ public LibraryImpl(IRI iri, OntologyProvider<?> cache) {
super(iri);
setCache(cache);
}
@@ -78,28 +86,30 @@ public class LibraryImpl extends Abstrac
* the library identifier and possible physical location.
* @param name
* the short name of this library.
- */
- public LibraryImpl(IRI iri, String name) {
- this(iri, name, OWLManager.createOWLOntologyManager());
- }
-
- /**
- * Creates a new instance of {@link LibraryImpl}.
- *
- * @param iri
- * the library identifier and possible physical location.
- * @param name
- * the short name of this library.
* @param cache
* the {@link OWLOntologyManager} to be used for caching ontologies in-memory.
*/
- public LibraryImpl(IRI iri, String name, OWLOntologyManager cache) {
+ public LibraryImpl(IRI iri, String name, OntologyProvider<?> cache) {
super(iri, name);
setCache(cache);
}
@Override
- public OWLOntologyManager getCache() {
+ public void addChild(RegistryItem child) throws RegistryContentException {
+ if (child instanceof Registry || child instanceof Library) throw new IllegalRegistryCycleException(
+ this, child, RegistryOperation.ADD_CHILD);
+ super.addChild(child);
+ }
+
+ @Override
+ public void addParent(RegistryItem parent) throws RegistryContentException {
+ if (parent instanceof RegistryOntology || parent instanceof Library) throw new IllegalRegistryCycleException(
+ this, parent, RegistryOperation.ADD_PARENT);
+ super.addParent(parent);
+ }
+
+ @Override
+ public OntologyProvider<?> getCache() {
return cache;
}
@@ -117,7 +127,11 @@ public class LibraryImpl extends Abstrac
Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
for (RegistryItem child : getChildren()) {
if (child instanceof RegistryOntology) {
- OWLOntology o = ((RegistryOntology) child).getRawOntology(this.getIRI());
+ String ref = ((RegistryOntology) child).getReference(getIRI());
+
+ OWLOntology o = (OWLOntology) getCache().getStoredOntology(ref, OWLOntology.class);
+
+ // OWLOntology o = ((RegistryOntology) child).getRawOntology(this.getIRI());
// Should never be null if the library was loaded correctly (an error should have already been
// thrown when loading it), but just in case.
if (o != null) ontologies.add(o);
@@ -128,6 +142,30 @@ public class LibraryImpl extends Abstrac
}
@Override
+ public OWLOntology getOntology(IRI id) throws RegistryContentException {
+ Object store = cache.getStore();
+ if (store instanceof WeightedTcProvider) {
+ WeightedTcProvider wtcp = (WeightedTcProvider) store;
+ TripleCollection tc = wtcp.getTriples(new UriRef(id.toString()));
+ return OWLAPIToClerezzaConverter.clerezzaGraphToOWLOntology(tc);
+ } else if (store instanceof OWLOntologyManager) {
+ OWLOntologyManager omgr = (OWLOntologyManager) store;
+ return omgr.getOntology(id);
+ } else throw new IllegalStateException(
+ "Library implementation was assigned an unsupported cache type.");
+ }
+
+ @Override
+ public String getOntologyReference(IRI ontologyId) throws RegistryContentException {
+
+ RegistryItem ri = getChild(ontologyId);
+ if (ri instanceof RegistryOntology) {
+ return ((RegistryOntology) ri).getReference(getIRI());
+ }
+ return null;
+ }
+
+ @Override
public Type getType() {
return type;
}
@@ -138,25 +176,68 @@ public class LibraryImpl extends Abstrac
}
@Override
- public synchronized void loadOntologies(OWLOntologyManager mgr) {
- if (mgr == null) throw new IllegalArgumentException("A null ontology manager is not allowed.");
+ public synchronized void loadOntologies(OntologyProvider<?> loader) {
+ if (loader == null) throw new IllegalArgumentException("A null loader is not allowed.");
for (RegistryItem item : getChildren()) {
if (item instanceof RegistryOntology) {
RegistryOntology o = (RegistryOntology) item;
IRI id = o.getIRI();
- try {
- o.setRawOntology(getIRI(), mgr.loadOntology(id));
- } catch (OWLOntologyAlreadyExistsException e) {
- o.setRawOntology(getIRI(), mgr.getOntology(e.getOntologyID()));
- } catch (OWLOntologyDocumentAlreadyExistsException e) {
- o.setRawOntology(getIRI(), mgr.getOntology(e.getOntologyDocumentIRI()));
- } catch (UnloadableImportException e) {
- log.warn("Import {} failed. Reason: {}", e.getImportsDeclaration().getURI(), e.getCause()
- .getLocalizedMessage());
- } catch (OWLOntologyCreationIOException e) {
- log.error("I/O error when loading ontology {}. Reason: {}", id, e.getCause().getClass());
- } catch (OWLOntologyCreationException e) {
- log.error("Failed to load ontology " + id, e);
+
+ if (true) {
+ try {
+ String key = loader.loadInStore(id, SupportedFormat.RDF_XML, false);
+ log.debug("Setting key {} for ontology {}", key, o);
+ o.setReference(getIRI(), key);
+ } catch (IOException ex) {
+ log.error("I/O error occurred loading {}", id);
+ }
+ } else {
+
+ Object store = loader.getStore();
+ if (store instanceof OWLOntologyManager) // Deprecated OWL API implementation.
+ {
+ OWLOntologyManager mgr = (OWLOntologyManager) store;
+ try {
+ o.setRawOntology(getIRI(), mgr.loadOntology(id));
+ } catch (OWLOntologyAlreadyExistsException e) {
+ o.setRawOntology(getIRI(), mgr.getOntology(e.getOntologyID()));
+ } catch (OWLOntologyDocumentAlreadyExistsException e) {
+ o.setRawOntology(getIRI(), mgr.getOntology(e.getOntologyDocumentIRI()));
+ } catch (UnloadableImportException e) {
+ log.warn("Import {} failed. Reason: {}", e.getImportsDeclaration().getURI(), e
+ .getCause().getLocalizedMessage());
+ } catch (OWLOntologyCreationIOException e) {
+ log.error("I/O error when loading ontology {}. Reason: {}", id, e.getCause()
+ .getClass());
+ } catch (OWLOntologyCreationException e) {
+ log.error("Failed to load ontology " + id, e);
+ }
+ } else if (store instanceof TcProvider) // Clerezza implementation
+ {
+ TcProvider wtcp = (TcProvider) store;
+ MGraph mg = null;
+ try {
+ mg = wtcp.createMGraph(new UriRef(id.toString()));
+ } catch (EntityAlreadyExistsException e) {
+ mg = wtcp.getMGraph(new UriRef(id.toString()));
+ }
+ if (mg != null) try {
+ // TODO use parser.getInstance() or something similar
+ Parser parser = Parser.getInstance();
+ final URLConnection con = id.toURI().toURL().openConnection();
+ con.addRequestProperty("Accept", "application/rdf+xml");
+ final InputStream is = con.getInputStream();
+ Graph deserializedGraph = parser.parse(is, SupportedFormat.RDF_XML);
+ mg.addAll(deserializedGraph);
+
+ // TODO imports!
+
+ o.setReference(getIRI(), id.toString());
+ } catch (IOException e) {
+ log.error("I/O error when loading ontology {}. Reason: {}", id, e);
+ }
+ } else throw new IllegalStateException(
+ "Library implementation was assigned an unsupported cache type.");
}
}
}
@@ -167,13 +248,21 @@ public class LibraryImpl extends Abstrac
public void removeChild(RegistryItem child) {
super.removeChild(child);
// Also unload the ontology version that comes from this library.
- if (child instanceof RegistryOntology) ((RegistryOntology) child).setRawOntology(getIRI(), null);
+ if (child instanceof RegistryOntology) ((RegistryOntology) child).setReference(getIRI(), null);
}
@Override
- public void setCache(OWLOntologyManager cache) {
- // TODO use the ontology manager factory.
- if (cache == null) cache = OWLManager.createOWLOntologyManager();
+ public void setCache(OntologyProvider<?> cache) {
+ if (cache == null) cache = new ClerezzaOntologyProvider(TcManager.getInstance(), null,
+ Parser.getInstance());
+ else {
+ Object store = cache.getStore();
+ if (!(store instanceof TcProvider || store instanceof OWLOntologyManager)) throw new IllegalArgumentException(
+ "Type "
+ + store.getClass()
+ + "is not supported. This ontology library implementation only supports caches based on either "
+ + TcProvider.class + " or " + OWLOntologyManager.class);
+ }
this.cache = cache;
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/RegistryOntologyImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/RegistryOntologyImpl.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/RegistryOntologyImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/impl/model/RegistryOntologyImpl.java Wed Nov 2 18:41:36 2011
@@ -31,7 +31,10 @@ import org.semanticweb.owlapi.model.OWLO
*/
public class RegistryOntologyImpl extends AbstractRegistryItem implements RegistryOntology {
- private Map<IRI,OWLOntology> owl = new HashMap<IRI,OWLOntology>();
+ @Deprecated
+ private Map<IRI,OWLOntology> ontologies = new HashMap<IRI,OWLOntology>();
+
+ private Map<IRI,String> references = new HashMap<IRI,String>();
public RegistryOntologyImpl(IRI iri) {
super(iri);
@@ -42,14 +45,20 @@ public class RegistryOntologyImpl extend
}
@Override
- public Map<IRI,OWLOntology> getRawOntologies() throws RegistryOntologyNotLoadedException {
- return owl;
+ public OWLOntology getRawOntology(IRI libraryID) throws RegistryOntologyNotLoadedException {
+ fireContentRequested(this);
+ return ontologies.get(libraryID);
}
@Override
- public OWLOntology getRawOntology(IRI libraryID) throws RegistryOntologyNotLoadedException {
+ public String getReference(IRI libraryID) throws RegistryOntologyNotLoadedException {
fireContentRequested(this);
- return owl.get(libraryID);
+ return references.get(libraryID);
+ }
+
+ @Override
+ public Map<IRI,String> getReferenceMap() throws RegistryOntologyNotLoadedException {
+ return references;
}
@Override
@@ -59,8 +68,15 @@ public class RegistryOntologyImpl extend
@Override
public void setRawOntology(IRI libraryID, OWLOntology owl) {
- if (owl == null) this.owl.remove(libraryID);
- this.owl.put(libraryID, owl);
+ if (owl == null) this.ontologies.remove(libraryID);
+ this.ontologies.put(libraryID, owl);
+ setReference(libraryID, owl.getOntologyID().getOntologyIRI().toString());
+ }
+
+ @Override
+ public void setReference(IRI libraryID, String reference) {
+ if (reference == null) this.references.remove(libraryID);
+ this.references.put(libraryID, reference);
}
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java Wed Nov 2 18:41:36 2011
@@ -73,7 +73,7 @@ public class LibrarySource extends Abstr
* the identifier of the ontology library.
*/
public LibrarySource(IRI libraryID) throws RegistryContentException {
- this(libraryID, new RegistryManagerImpl(null, new Hashtable<String,Object>()));
+ this(libraryID, new RegistryManagerImpl(null, null, new Hashtable<String,Object>()));
}
/**
@@ -156,7 +156,7 @@ public class LibrarySource extends Abstr
"A null registry manager is not allowed");
this.libraryID = libraryID;
-
+
// The ontology that imports the whole network is created in-memory, therefore it has no physical IRI
// unless it is borrowed from the supplied parent.
bindPhysicalIri(parentSrc != null ? parentSrc.getPhysicalIRI() : null);
@@ -192,7 +192,7 @@ public class LibrarySource extends Abstr
public String toString() {
return "LIBRARY<" + libraryID + ">";
}
-
+
private Set<OWLOntology> ontologies;
@Override
Added: incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/MockOsgiContext.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/MockOsgiContext.java?rev=1196752&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/MockOsgiContext.java (added)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/MockOsgiContext.java Wed Nov 2 18:41:36 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.registry;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
+import org.apache.clerezza.rdf.rdfjson.parser.RdfJsonParsingProvider;
+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());
+
+ parser = new Parser();
+ parser.bindParsingProvider(new JenaParserProvider());
+ parser.bindParsingProvider(new RdfJsonParsingProvider());
+ }
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyLibrary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyLibrary.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyLibrary.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyLibrary.java Wed Nov 2 18:41:36 2011
@@ -16,7 +16,12 @@
*/
package org.apache.stanbol.ontologymanager.registry;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import static org.apache.stanbol.ontologymanager.registry.MockOsgiContext.*;
import java.io.File;
import java.net.URL;
@@ -24,9 +29,12 @@ import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Set;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.simple.storage.SimpleTcProvider;
import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryManager;
import org.apache.stanbol.ontologymanager.registry.api.model.Library;
import org.apache.stanbol.ontologymanager.registry.api.model.Registry;
@@ -64,6 +72,7 @@ public class TestOntologyLibrary {
final Dictionary<String,Object> config = new Hashtable<String,Object>();
config.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] {"/ontologies", "/ontologies/registry"});
offline = new OfflineConfigurationImpl(config);
+ reset();
}
private String registryResourcePath = "/ontologies/registry/onmtest.owl";
@@ -76,7 +85,8 @@ public class TestOntologyLibrary {
* Resets the registry manager, which each unit test needs to reconfigure individually.
*/
@After
- public void reset() {
+ public void cleanup() {
+ reset();
regMgr = null;
}
@@ -115,7 +125,8 @@ public class TestOntologyLibrary {
Dictionary<String,Object> regmanConf = new Hashtable<String,Object>();
regmanConf.put(RegistryManager.REGISTRY_LOCATIONS, new String[] {localTestRegistry.toString()});
// Instantiating the registry manager will also load the registry data.
- regMgr = new RegistryManagerImpl(offline, regmanConf);
+ regMgr = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(tcManager, offline, parser),
+ regmanConf);
// The resulting manager must exist and have exactly one registry.
assertNotNull(regMgr);
@@ -155,11 +166,13 @@ public class TestOntologyLibrary {
Dictionary<String,Object> regmanConf = new Hashtable<String,Object>();
regmanConf.put(RegistryManager.REGISTRY_LOCATIONS, new String[] {localTestRegistry.toString()});
// Instantiating the registry manager will also load the registry data.
- regMgr = new RegistryManagerImpl(offline, regmanConf);
+ regMgr = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(tcManager,
+ offline, parser), regmanConf);
assertNotNull(regMgr);
// Now use this registry manager to instantiate an input source.
- OntologyInputSource<OWLOntology> src = new LibrarySource(Locations.LIBRARY_TEST1, regMgr, virginOntologyManager);
+ OntologyInputSource<OWLOntology> src = new LibrarySource(Locations.LIBRARY_TEST1, regMgr,
+ virginOntologyManager);
OWLOntology o = src.getRootOntology();
boolean hasImporting = false, hasImported = false;
for (OWLImportsDeclaration ax : o.getImportsDeclarations()) {
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=1196752&r1=1196751&r2=1196752&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 Wed Nov 2 18:41:36 2011
@@ -28,10 +28,13 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.Set;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.simple.storage.SimpleTcProvider;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryManager;
import org.apache.stanbol.ontologymanager.registry.api.model.Registry;
import org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem;
@@ -65,7 +68,7 @@ public class TestOntologyRegistry {
config.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] {"/ontologies", "/ontologies/registry"});
OfflineConfiguration offline = new OfflineConfigurationImpl(config);
// The registry manager can be updated via calls to createModel()
- regman = new RegistryManagerImpl(offline, config);
+ regman = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(new SimpleTcProvider(),offline,new Parser()), config);
// An ONManager with no storage support and same offline settings as the registry manager.
onm = new ONManagerImpl(null, null, offline, config);
}
Modified: incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestRegistryManager.java Wed Nov 2 18:41:36 2011
@@ -16,6 +16,7 @@
*/
package org.apache.stanbol.ontologymanager.registry;
+import static org.apache.stanbol.ontologymanager.registry.MockOsgiContext.*;
import static org.junit.Assert.*;
import java.util.Dictionary;
@@ -23,17 +24,19 @@ import java.util.Hashtable;
import java.util.Iterator;
import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
import org.apache.stanbol.ontologymanager.registry.api.RegistryManager;
import org.apache.stanbol.ontologymanager.registry.api.model.CachingPolicy;
import org.apache.stanbol.ontologymanager.registry.api.model.Library;
import org.apache.stanbol.ontologymanager.registry.api.model.Registry;
import org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem;
import org.apache.stanbol.ontologymanager.registry.impl.RegistryManagerImpl;
+import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.semanticweb.owlapi.model.OWLOntologyManager;
/**
* Test the correct creation and setup of {@link RegistryManager} implementations.
@@ -57,6 +60,7 @@ public class TestRegistryManager {
*/
@BeforeClass
public static void setup() throws Exception {
+
configuration = new Hashtable<String,Object>();
// We need this to make sure the local meta.owl (which does not import codolight) is loaded.
configuration.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] {"/ontologies",
@@ -69,13 +73,24 @@ public class TestRegistryManager {
TestRegistryManager.class.getResource("/ontologies/registry/onmtest_additions.owl")
.toString()});
offline = new OfflineConfigurationImpl(configuration);
+
+ reset();
+
}
private RegistryManager regman;
+ private OntologyProvider<?> provider;
+
@Before
public void setupTests() throws Exception {}
+ @After
+ public void cleanup() throws Exception {
+ reset();
+ provider = new ClerezzaOntologyProvider(tcManager, offline, parser);
+ }
+
/**
* Verifies that by instantiating a new {@link RegistryManager} with a centralised caching policy and
* loading two registries, they share the same cache ontology manager.
@@ -86,13 +101,13 @@ public class TestRegistryManager {
public void testCachingCentralised() throws Exception {
// Change the caching policy and setup a new registry manager.
configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.CENTRALISED);
- regman = new RegistryManagerImpl(offline, configuration);
+ regman = new RegistryManagerImpl(offline, provider, configuration);
// Check that the configuration was set.
assertNotNull(regman);
assertSame(CachingPolicy.CENTRALISED, regman.getCachingPolicy());
// All registries must have the same cache.
Iterator<Library> it = regman.getLibraries().iterator();
- OWLOntologyManager cache = it.next().getCache();
+ OntologyProvider<?> cache = it.next().getCache();
while (it.hasNext())
assertSame(cache, it.next().getCache());
@@ -124,13 +139,13 @@ public class TestRegistryManager {
public void testCachingDistributed() throws Exception {
// Change the caching policy and setup a new registry manager.
configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.DISTRIBUTED);
- regman = new RegistryManagerImpl(offline, configuration);
+ regman = new RegistryManagerImpl(offline, provider, configuration);
// Check that the configuration was set.
assertNotNull(regman);
assertSame(CachingPolicy.DISTRIBUTED, regman.getCachingPolicy());
// Each registry must have its own distinct cache.
Iterator<Library> it = regman.getLibraries().iterator();
- OWLOntologyManager cache = it.next().getCache();
+ OntologyProvider<?> cache = it.next().getCache();
// Just checking against the first in the list.
while (it.hasNext()) {
assertNotSame(cache, it.next().getCache());
@@ -148,7 +163,7 @@ public class TestRegistryManager {
// Change the caching policy and setup a new registry manager.
configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.DISTRIBUTED);
configuration.put(RegistryManager.LAZY_LOADING, false);
- regman = new RegistryManagerImpl(offline, configuration);
+ regman = new RegistryManagerImpl(offline, provider, configuration);
// Check that the configuration was set.
assertNotNull(regman);
@@ -181,13 +196,13 @@ public class TestRegistryManager {
// Change the caching policy and setup a new registry manager.
configuration.put(RegistryManager.CACHING_POLICY, CachingPolicy.CENTRALISED);
configuration.put(RegistryManager.LAZY_LOADING, true);
- regman = new RegistryManagerImpl(offline, configuration);
+ regman = new RegistryManagerImpl(offline, provider, configuration);
// Check that the configuration was set.
assertNotNull(regman);
// Now pick a library.
Registry reg;
- Iterator<Registry> it =regman.getRegistries().iterator();
+ Iterator<Registry> it = regman.getRegistries().iterator();
do
reg = it.next();
// We need a registry with at least 2 libraries to check that only one will be loaded.
@@ -202,7 +217,7 @@ public class TestRegistryManager {
if (children[i] instanceof Library) lib1 = (Library) (children[i]);
if (children[i + 1] instanceof Library) lib2 = (Library) (children[i + 1]);
}
- assertFalse(lib1==lib2);
+ assertFalse(lib1 == lib2);
assertNotNull(lib1);
// ...but its ontologies must not be loaded yet.
assertFalse(lib1.isLoaded());
Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java Wed Nov 2 18:41:36 2011
@@ -202,8 +202,6 @@ public class ScopeResource extends BaseS
// First thing, check the core source.
try {
coreSrc = new LibrarySource(IRI.create(coreRegistry.replace("%23", "#")), regMgr);
- System.out.println("DIOPORCO");
- System.out.println(coreSrc);
} catch (Exception e1) {
// Bad or not supplied core registry, try the ontology.
try {
@@ -235,27 +233,19 @@ public class ScopeResource extends BaseS
// Expand core sources
List<OntologyInputSource> expanded = new ArrayList<OntologyInputSource>();
if (coreSrc != null) {
- System.out.println("CORRE " + coreSrc.getClass() + " " + coreSrc);
if (coreSrc instanceof OntologySetInputSource) {
- System.out.println("Root ontology " + coreSrc.getRootOntology());
for (OWLOntology o : ((OntologySetInputSource) coreSrc).getOntologies()) {
-
- System.out.println("\t" + o);
expanded.add(new RootOntologySource(o));
}
} else expanded.add(coreSrc);
}
if (custSrc != null) {
- System.out.println("CUSST " + custSrc.getClass());
if (custSrc instanceof OntologySetInputSource) for (OWLOntology o : ((OntologySetInputSource) custSrc)
.getOntologies())
expanded.add(new RootOntologySource(o));
else expanded.add(custSrc);
}
- for (OntologyInputSource s : expanded)
- System.out.println("Expanded Core Source " + s);
-
// Invoke the appropriate factory method depending on the
// availability of a custom source.
// scope = (custSrc != null) ? f.createOntologyScope(scopeid, coreSrc, custSrc) : f
Modified: incubator/stanbol/trunk/reengineer/db/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/db/pom.xml?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/db/pom.xml (original)
+++ incubator/stanbol/trunk/reengineer/db/pom.xml Wed Nov 2 18:41:36 2011
@@ -153,6 +153,11 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.jena.serializer</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
<artifactId>rdf.jena.sparql</artifactId>
<scope>test</scope>
</dependency>
Modified: incubator/stanbol/trunk/reengineer/xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/pom.xml?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/pom.xml (original)
+++ incubator/stanbol/trunk/reengineer/xml/pom.xml Wed Nov 2 18:41:36 2011
@@ -158,6 +158,11 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.jena.serializer</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
<artifactId>rdf.jena.sparql</artifactId>
<scope>test</scope>
</dependency>
Modified: incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java (original)
+++ incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java Wed Nov 2 18:41:36 2011
@@ -16,7 +16,7 @@
*/
package org.apache.stanbol.reengineer.xml;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
import java.io.InputStream;
import java.util.Dictionary;
@@ -24,6 +24,7 @@ import java.util.Hashtable;
import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
import org.apache.clerezza.rdf.core.sparql.QueryEngine;
import org.apache.clerezza.rdf.jena.sparql.JenaSparqlEngine;
import org.apache.clerezza.rdf.simple.storage.SimpleTcProvider;
@@ -31,6 +32,7 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.ontonet.api.OfflineConfiguration;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
import org.apache.stanbol.ontologymanager.ontonet.impl.OfflineConfigurationImpl;
+import org.apache.stanbol.ontologymanager.ontonet.impl.clerezza.ClerezzaOntologyProvider;
import org.apache.stanbol.reengineer.base.api.DataSource;
import org.apache.stanbol.reengineer.base.api.Reengineer;
import org.apache.stanbol.reengineer.base.api.util.ReengineerType;
@@ -120,7 +122,7 @@ public class XMLReengineerTest {
TcManager tcm = new SpecialTcManager(qe, wtcp);
// Two different ontology storages, the same sparql engine and tcprovider
- ONManager onManager = new ONManagerImpl(tcm, wtcp, offline, emptyConf);
+ ONManager onManager = new ONManagerImpl(new ClerezzaOntologyProvider(tcm, offline, new Parser()), offline, emptyConf);
xmlExtractor = new XMLExtractor(new ReengineerManagerImpl(emptyConf), onManager, emptyConf);
}
Modified: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRecipeTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRecipeTest.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRecipeTest.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRecipeTest.java Wed Nov 2 18:41:36 2011
@@ -30,6 +30,7 @@ import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
+import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
import org.apache.stanbol.rules.base.api.RuleStore;
@@ -66,7 +67,7 @@ public class AddRecipeTest {
@Before
public void setUp() {
Dictionary<String, Object> configuration = new Hashtable<String, Object>();
- onm = new ONManagerImpl(null,null,configuration);
+ onm = new ONManagerImpl((TcManager) null,null,configuration);
store = new RuleStoreImpl(onm, configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
}
Modified: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRuleTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRuleTest.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRuleTest.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/AddRuleTest.java Wed Nov 2 18:41:36 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.
+ */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
+import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
import org.apache.stanbol.rules.base.api.RuleStore;
@@ -44,33 +45,31 @@ import org.semanticweb.owlapi.model.OWLN
import org.semanticweb.owlapi.model.OWLOntology;
/**
- *
+ *
* @author elvio
*/
public class AddRuleTest {
- public AddRuleTest() {
- }
+ public AddRuleTest() {}
@BeforeClass
- public static void setUpClass() throws Exception {
- }
+ public static void setUpClass() throws Exception {}
@AfterClass
- public static void tearDownClass() throws Exception {
- }
+ public static void tearDownClass() throws Exception {}
@Before
public void setUp() {
- Dictionary<String, Object> configuration = new Hashtable<String, Object>();
- onm = new ONManagerImpl(null,null,configuration);
- store = new RuleStoreImpl(onm, configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ Dictionary<String,Object> configuration = new Hashtable<String,Object>();
+ onm = new ONManagerImpl((TcManager) null, null, configuration);
+ store = new RuleStoreImpl(onm, configuration,
+ "./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
}
@After
public void tearDown() {
- store = null;
- onm = null;
+ store = null;
+ onm = null;
}
public RuleStore store = null;
@@ -81,23 +80,24 @@ public class AddRuleTest {
*/
@Test
public void testAddRule_3args_1() {
-// RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ // RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
String ruleName = "MyRuleA";
String ruleBodyHead = "MyRuleABody -> MyRuleAHead";
String ruleDescription = "My comment to the rule A";
AddRule instance = new AddRule(store);
-
+
boolean result = instance.addRule(ruleName, ruleBodyHead, ruleDescription);
OWLOntology newonto = instance.getStore().getOntology();
- String ID = newonto.getOntologyID().toString().replace("<","").replace(">","")+"#";
+ String ID = newonto.getOntologyID().toString().replace("<", "").replace(">", "") + "#";
- if(result){
- OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID + "MyRuleA"));
+ if (result) {
+ OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory()
+ .getOWLNamedIndividual(IRI.create(ID + "MyRuleA"));
int axiom = newonto.getAxioms(ruleind).size();
- assertEquals(3,axiom);
+ assertEquals(3, axiom);
// TODO review the generated test code and remove the default call to fail.
- }else{
+ } else {
fail("Some problem occurs with addRule of KReSAddRule");
}
}
@@ -107,10 +107,10 @@ public class AddRuleTest {
*/
@Test
public void testAddRule_3args_2() {
-// RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ // RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
OWLOntology owl = store.getOntology();
- String ID = owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
- IRI ruleName = IRI.create(ID+"MyRuleA");
+ String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "") + "#";
+ IRI ruleName = IRI.create(ID + "MyRuleA");
String ruleBodyHead = "MyRuleABody -> MyRuleAHead";
String ruleDescription = "My comment to the rule A";
AddRule instance = new AddRule(store);
@@ -118,12 +118,13 @@ public class AddRuleTest {
boolean result = instance.addRule(ruleName, ruleBodyHead, ruleDescription);
OWLOntology newonto = instance.getStore().getOntology();
- if(result){
- OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(ruleName);
+ if (result) {
+ OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory()
+ .getOWLNamedIndividual(ruleName);
int axiom = newonto.getAxioms(ruleind).size();
- assertEquals(3,axiom);
+ assertEquals(3, axiom);
// TODO review the generated test code and remove the default call to fail.
- }else{
+ } else {
fail("Some problem occurs with addRule of KReSAddRule");
}
}
@@ -133,32 +134,33 @@ public class AddRuleTest {
*/
@Test
public void testAddRuleMap() {
-// RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ // RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
OWLOntology owl = store.getOntology();
- String ID = owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
- HashMap<String, String> ruleBodyHeadMap = new HashMap();
- HashMap<String, String> ruleDescriptionMap = new HashMap();
-
- ruleBodyHeadMap.put("MyRuleA","MyRuleABody -> MyRuleAHead");
- ruleBodyHeadMap.put("MyRuleB","MyRuleBBody -> MyRuleBHead");
- ruleDescriptionMap.put("MyRuleA","My comment to the rule A");
- ruleDescriptionMap.put("MyRuleB","My comment to the rule B");
+ String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "") + "#";
+ HashMap<String,String> ruleBodyHeadMap = new HashMap();
+ HashMap<String,String> ruleDescriptionMap = new HashMap();
+
+ ruleBodyHeadMap.put("MyRuleA", "MyRuleABody -> MyRuleAHead");
+ ruleBodyHeadMap.put("MyRuleB", "MyRuleBBody -> MyRuleBHead");
+ ruleDescriptionMap.put("MyRuleA", "My comment to the rule A");
+ ruleDescriptionMap.put("MyRuleB", "My comment to the rule B");
AddRule instance = new AddRule(store);
-
+
boolean result = instance.addRuleMap(ruleBodyHeadMap, ruleDescriptionMap);
OWLOntology newonto = instance.getStore().getOntology();
- if(result){
+ if (result) {
Iterator<String> keys = ruleBodyHeadMap.keySet().iterator();
int axiom = 0;
- while(keys.hasNext()){
- OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID+keys.next()));
+ while (keys.hasNext()) {
+ OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory()
+ .getOWLNamedIndividual(IRI.create(ID + keys.next()));
axiom = axiom + newonto.getAxioms(ruleind).size();
}
- assertEquals(6,axiom);
+ assertEquals(6, axiom);
// TODO review the generated test code and remove the default call to fail.
- }else{
+ } else {
fail("Some problem occurs with addRuleMap of KReSAddRule");
}
}
@@ -168,32 +170,33 @@ public class AddRuleTest {
*/
@Test
public void testAddRuleMapIRI() {
-// RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ // RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
OWLOntology owl = store.getOntology();
- String ID = owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
- HashMap<IRI, String> ruleBodyHeadMap = new HashMap();
- HashMap<IRI, String> ruleDescriptionMap = new HashMap();
-
- ruleBodyHeadMap.put(IRI.create(ID+"MyRuleA"),"MyRuleABody -> MyRuleAHead");
- ruleBodyHeadMap.put(IRI.create(ID+"MyRuleB"),"MyRuleBBody -> MyRuleBHead");
- ruleDescriptionMap.put(IRI.create(ID+"MyRuleA"),"My comment to the rule A");
- ruleDescriptionMap.put(IRI.create(ID+"MyRuleB"),"My comment to the rule B");
+ String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "") + "#";
+ HashMap<IRI,String> ruleBodyHeadMap = new HashMap();
+ HashMap<IRI,String> ruleDescriptionMap = new HashMap();
+
+ ruleBodyHeadMap.put(IRI.create(ID + "MyRuleA"), "MyRuleABody -> MyRuleAHead");
+ ruleBodyHeadMap.put(IRI.create(ID + "MyRuleB"), "MyRuleBBody -> MyRuleBHead");
+ ruleDescriptionMap.put(IRI.create(ID + "MyRuleA"), "My comment to the rule A");
+ ruleDescriptionMap.put(IRI.create(ID + "MyRuleB"), "My comment to the rule B");
AddRule instance = new AddRule(store);
boolean result = instance.addRuleMapIRI(ruleBodyHeadMap, ruleDescriptionMap);
OWLOntology newonto = instance.getStore().getOntology();
- if(result){
+ if (result) {
Iterator<IRI> keys = ruleBodyHeadMap.keySet().iterator();
int axiom = 0;
- while(keys.hasNext()){
- OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(keys.next());
+ while (keys.hasNext()) {
+ OWLNamedIndividual ruleind = newonto.getOWLOntologyManager().getOWLDataFactory()
+ .getOWLNamedIndividual(keys.next());
axiom = axiom + newonto.getAxioms(ruleind).size();
}
- assertEquals(6,axiom);
+ assertEquals(6, axiom);
// TODO review the generated test code and remove the default call to fail.
- }else{
+ } else {
fail("Some problem occurs with addRuleMap of KReSAddRule");
}
}
Modified: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/GetRecipeTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/GetRecipeTest.java?rev=1196752&r1=1196751&r2=1196752&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/GetRecipeTest.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/GetRecipeTest.java Wed Nov 2 18:41:36 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.
+ */
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
@@ -28,6 +28,7 @@ import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
+import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
import org.apache.stanbol.ontologymanager.ontonet.impl.ONManagerImpl;
import org.apache.stanbol.rules.base.api.RuleStore;
@@ -43,33 +44,31 @@ import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
/**
- *
+ *
* @author elvio
*/
public class GetRecipeTest {
- public GetRecipeTest() {
- }
+ public GetRecipeTest() {}
@BeforeClass
- public static void setUpClass() throws Exception {
- }
+ public static void setUpClass() throws Exception {}
@AfterClass
- public static void tearDownClass() throws Exception {
- }
+ public static void tearDownClass() throws Exception {}
@Before
public void setUp() {
- Dictionary<String, Object> configuration = new Hashtable<String, Object>();
- onm = new ONManagerImpl(null,null,configuration);
- store = new RuleStoreImpl(onm, configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ Dictionary<String,Object> configuration = new Hashtable<String,Object>();
+ onm = new ONManagerImpl((TcManager) null, null, configuration);
+ store = new RuleStoreImpl(onm, configuration,
+ "./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
}
@After
public void tearDown() {
- store = null;
- onm = null;
+ store = null;
+ onm = null;
}
public RuleStore store = null;
@@ -80,22 +79,26 @@ public class GetRecipeTest {
*/
@Test
public void testGetRecipe() {
-// RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ // RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
OWLOntology owl = store.getOntology();
-
- String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "")+"#";
- //Load the example file
- LoadRuleFile load = new LoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+
+ String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "") + "#";
+ // Load the example file
+ LoadRuleFile load = new LoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",
+ store);
owl = load.getStore().getOntology();
GetRecipe rule = new GetRecipe(store);
- HashMap<IRI, String> map = rule.getRecipe(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRecipe"));
- HashMap<IRI, String> expmap = new HashMap();
- expmap.put(IRI.create(ID+"MyRecipe"), "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA");
- if(map!=null){
- assertEquals(expmap, map);
- // TODO review the generated test code and remove the default call to fail.
- }else{
- fail("Some error occurs for method GetRecipe of KReSGetRecipe");
+ HashMap<IRI,String> map = rule.getRecipe(IRI
+ .create("http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRecipe"));
+ HashMap<IRI,String> expmap = new HashMap();
+ expmap.put(
+ IRI.create(ID + "MyRecipe"),
+ "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA");
+ if (map != null) {
+ assertEquals(expmap, map);
+ // TODO review the generated test code and remove the default call to fail.
+ } else {
+ fail("Some error occurs for method GetRecipe of KReSGetRecipe");
}
}
@@ -104,27 +107,34 @@ public class GetRecipeTest {
*/
@Test
public void testGetAllRecipes() {
-// RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+ // RuleStore store = new RuleStoreImpl("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
OWLOntology owl = store.getOntology();
- String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "")+"#";
- //Load the example file
- LoadRuleFile load = new LoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+ String ID = owl.getOntologyID().toString().replace("<", "").replace(">", "") + "#";
+ // Load the example file
+ LoadRuleFile load = new LoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",
+ store);
owl = load.getStore().getOntology();
GetRecipe rule = new GetRecipe(store);
- HashMap<IRI, String> map = rule.getAllRecipes();
- HashMap<IRI, String> expmap = new HashMap();
- expmap.put(IRI.create(ID+"MyRecipe"), "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA");
- expmap.put(IRI.create(ID+"MyRecipe2"), "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleE, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD");
- expmap.put(IRI.create(ID+"MyRecipe3"), "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF");
- expmap.put(IRI.create(ID+"MyRecipe4"), "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD");
-
- if(map!=null){
- assertEquals(expmap, map);
- // TODO review the generated test code and remove the default call to fail.
- }else{
- fail("Some error occurs for method GetAllRecipe of KReSGetRecipe");
+ HashMap<IRI,String> map = rule.getAllRecipes();
+ HashMap<IRI,String> expmap = new HashMap();
+ expmap.put(
+ IRI.create(ID + "MyRecipe"),
+ "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA");
+ expmap.put(
+ IRI.create(ID + "MyRecipe2"),
+ "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleE, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD");
+ expmap.put(IRI.create(ID + "MyRecipe3"), "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF");
+ expmap.put(
+ IRI.create(ID + "MyRecipe4"),
+ "http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD");
+
+ if (map != null) {
+ assertEquals(expmap, map);
+ // TODO review the generated test code and remove the default call to fail.
+ } else {
+ fail("Some error occurs for method GetAllRecipe of KReSGetRecipe");
}
}