Search in sources :

Example 1 with ClerezzaOntologyProvider

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.

the class TestOntologyRegistry method setup.

/**
     * Sets the registry and ontology network managers, which are immutable across tests.
     */
@BeforeClass
public static void setup() {
    // We use a single Dictionary for storing all configurations.
    final Dictionary<String, Object> config = new Hashtable<String, Object>();
    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, new ClerezzaOntologyProvider(new SimpleTcProvider(), offline, Parser.getInstance()), config);
}
Also used : Hashtable(java.util.Hashtable) SimpleTcProvider(org.apache.clerezza.rdf.simple.storage.SimpleTcProvider) RegistryManagerImpl(org.apache.stanbol.ontologymanager.registry.impl.RegistryManagerImpl) OfflineConfigurationImpl(org.apache.stanbol.ontologymanager.core.OfflineConfigurationImpl) OfflineConfiguration(org.apache.stanbol.ontologymanager.servicesapi.OfflineConfiguration) ClerezzaOntologyProvider(org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider) BeforeClass(org.junit.BeforeClass)

Example 2 with ClerezzaOntologyProvider

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.

the class TestClerezzaSpaces method setup.

@BeforeClass
public static void setup() throws Exception {
    offline = new OfflineConfigurationImpl(new Hashtable<String, Object>());
    ScopeRegistry reg = new ScopeRegistryImpl();
    // This one is created from scratch
    Graph ont2 = ClerezzaOWLUtils.createOntology(baseIri2.toString());
    minorSrc = new GraphSource(ont2.getImmutableGraph());
    dropSrc = getLocalSource("/ontologies/droppedcharacters.owl");
    nonexSrc = getLocalSource("/ontologies/nonexistentcharacters.owl");
    inMemorySrc = new ParentPathInputSource(new File(TestClerezzaSpaces.class.getResource("/ontologies/maincharacters.owl").toURI()));
    OWLDataFactory df = OWLManager.getOWLDataFactory();
    OWLClass cHuman = df.getOWLClass(IRI.create(baseIri + "/" + Constants.humanBeing));
    OWLIndividual iLinus = df.getOWLNamedIndividual(IRI.create(baseIri + "/" + Constants.linus));
    linusIsHuman = df.getOWLClassAssertionAxiom(cHuman, iLinus);
    factory = new ClerezzaCollectorFactory(new ClerezzaOntologyProvider(tcManager, offline, parser), new Hashtable<String, Object>());
    factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
}
Also used : Hashtable(java.util.Hashtable) OfflineConfigurationImpl(org.apache.stanbol.ontologymanager.core.OfflineConfigurationImpl) ClerezzaOntologyProvider(org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider) Graph(org.apache.clerezza.commons.rdf.Graph) ScopeRegistryImpl(org.apache.stanbol.ontologymanager.core.scope.ScopeRegistryImpl) GraphSource(org.apache.stanbol.ontologymanager.sources.clerezza.GraphSource) ParentPathInputSource(org.apache.stanbol.ontologymanager.sources.owlapi.ParentPathInputSource) OWLClass(org.semanticweb.owlapi.model.OWLClass) OWLDataFactory(org.semanticweb.owlapi.model.OWLDataFactory) File(java.io.File) ScopeRegistry(org.apache.stanbol.ontologymanager.servicesapi.scope.ScopeRegistry) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual) ClerezzaCollectorFactory(org.apache.stanbol.ontologymanager.multiplexer.clerezza.collector.ClerezzaCollectorFactory) BeforeClass(org.junit.BeforeClass)

Example 3 with ClerezzaOntologyProvider

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.

the class MockOsgiContext method reset.

/**
     * Sets up a new mock OSGi context and cleans all resources and components.
     */
public static void reset() {
    // reset Clerezza objects
    tcManager = new TcManager();
    tcManager.addWeightedTcProvider(new SimpleTcProvider());
    // reset Stanbol objects
    ontologyProvider = new ClerezzaOntologyProvider(tcManager, offline, parser);
    collectorfactory = new ClerezzaCollectorFactory(ontologyProvider, config);
    resetManagers();
}
Also used : TcManager(org.apache.clerezza.rdf.core.access.TcManager) SimpleTcProvider(org.apache.clerezza.rdf.simple.storage.SimpleTcProvider) ClerezzaOntologyProvider(org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider) ClerezzaCollectorFactory(org.apache.stanbol.ontologymanager.multiplexer.clerezza.collector.ClerezzaCollectorFactory)

Example 4 with ClerezzaOntologyProvider

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.

the class TestOntologyLibrary method testLibraryLoad.

/**
     * Uses a plain {@link RegistryManager} to load a single ontology library and checks for its expected hits
     * and misses.
     * 
     * @throws Exception
     *             if any error occurs;
     */
@Test
public void testLibraryLoad() throws Exception {
    IRI localTestRegistry = IRI.create(getClass().getResource(registryResourcePath));
    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, new ClerezzaOntologyProvider(tcManager, offline, parser), regmanConf);
    // The resulting manager must exist and have exactly one registry.
    assertNotNull(regMgr);
    Set<Registry> registries = regMgr.getRegistries();
    assertFalse(registries.isEmpty());
    assertEquals(1, registries.size());
    Registry reg = registries.iterator().next();
    assertTrue(reg.hasChildren());
    Library lib = null;
    // Look for test #Library2
    for (RegistryItem item : reg.getChildren()) {
        if (Locations.LIBRARY_TEST2.equals(item.getIRI())) {
            lib = (Library) item;
            break;
        }
    }
    assertNotNull(lib);
    // Should be in the library.
    boolean hasShould = RegistryUtils.containsOntologyRecursive(lib, Locations.CHAR_DROPPED);
    // Should NOT be in the library (belongs to another library in the same registry).
    boolean hasShouldNot = RegistryUtils.containsOntologyRecursive(lib, Locations.CHAR_ACTIVE);
    assertTrue(hasShould);
    assertFalse(hasShouldNot);
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) Hashtable(java.util.Hashtable) RegistryManagerImpl(org.apache.stanbol.ontologymanager.registry.impl.RegistryManagerImpl) Registry(org.apache.stanbol.ontologymanager.registry.api.model.Registry) Library(org.apache.stanbol.ontologymanager.registry.api.model.Library) RegistryItem(org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem) ClerezzaOntologyProvider(org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider) Test(org.junit.Test)

Example 5 with ClerezzaOntologyProvider

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.

the class TestOntologyLibrary method testLibrarySourceCreation.

/**
     * Tests the creation of an ontology input source from a single library. Because the test is run offline,
     * import statements might be file URIs, so tests should not fail on this.
     * 
     * @throws Exception
     */
@Test
public void testLibrarySourceCreation() throws Exception {
    IRI localTestRegistry = IRI.create(getClass().getResource(registryResourcePath));
    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, 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);
    OWLOntology o = src.getRootOntology();
    boolean hasImporting = false, hasImported = false;
    for (OWLImportsDeclaration ax : o.getImportsDeclarations()) {
        // Since we added a local IRI mapping, import statements might be using file: IRIs instead of
        // HTTP, in which case IRI equality would fail. So it is enough here to just check the filename.
        String tmpstr = ax.getIRI().toString();
        if (!hasImporting && tmpstr.endsWith("characters_all.owl"))
            hasImporting = true;
        else if (!hasImported && tmpstr.endsWith("maincharacters.owl"))
            hasImported = true;
        if (hasImporting && hasImported)
            break;
    }
    assertTrue(hasImporting);
    assertTrue(hasImported);
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) Hashtable(java.util.Hashtable) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) LibrarySource(org.apache.stanbol.ontologymanager.registry.io.LibrarySource) RegistryManagerImpl(org.apache.stanbol.ontologymanager.registry.impl.RegistryManagerImpl) OWLImportsDeclaration(org.semanticweb.owlapi.model.OWLImportsDeclaration) ClerezzaOntologyProvider(org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider) Test(org.junit.Test)

Aggregations

ClerezzaOntologyProvider (org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider)7 Hashtable (java.util.Hashtable)4 RegistryManagerImpl (org.apache.stanbol.ontologymanager.registry.impl.RegistryManagerImpl)3 IRI (org.semanticweb.owlapi.model.IRI)3 SimpleTcProvider (org.apache.clerezza.rdf.simple.storage.SimpleTcProvider)2 OfflineConfigurationImpl (org.apache.stanbol.ontologymanager.core.OfflineConfigurationImpl)2 ClerezzaCollectorFactory (org.apache.stanbol.ontologymanager.multiplexer.clerezza.collector.ClerezzaCollectorFactory)2 Library (org.apache.stanbol.ontologymanager.registry.api.model.Library)2 Registry (org.apache.stanbol.ontologymanager.registry.api.model.Registry)2 RegistryItem (org.apache.stanbol.ontologymanager.registry.api.model.RegistryItem)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)2 File (java.io.File)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Graph (org.apache.clerezza.commons.rdf.Graph)1 TcManager (org.apache.clerezza.rdf.core.access.TcManager)1 ScopeRegistryImpl (org.apache.stanbol.ontologymanager.core.scope.ScopeRegistryImpl)1 RegistryContentException (org.apache.stanbol.ontologymanager.registry.api.RegistryContentException)1