Package org.apache.stanbol.ontologymanager.registry.api.model

Examples of org.apache.stanbol.ontologymanager.registry.api.model.Registry


    }

    protected Registry populateRegistry(OWLOntology registry) throws RegistryContentException {

        log.debug("Populating registry content from ontology {}", registry);
        Registry reg = riFactory.createRegistry(registry);
        Set<OWLOntology> closure = registry.getOWLOntologyManager().getImportsClosure(registry);

        // Just scan all individuals. Recurse in case the registry imports more registries.
        for (OWLIndividual ind : registry.getIndividualsInSignature(true)) {
            // We do not allow anonymous registry items.
            if (ind.isAnonymous()) continue;
            RegistryItem item = null;
            // IRI id = ind.asOWLNamedIndividual().getIRI();
            Type t = RegistryUtils.getType(ind, closure);
            if (t == null) {
                log.warn("Undetermined type for registry ontology individual {}", ind);
                continue;
            }
            switch (t) {
                case LIBRARY:
                    log.debug("Found library for individual {}", ind);
                    // Create the library and attach to parent and children
                    item = populateLibrary(ind.asOWLNamedIndividual(), closure);
                    reg.addChild(item);
                    item.addRegistryContentListener(this);
                    break;
                case ONTOLOGY:
                    log.debug("Found ontology for individual {}", ind);
                    // Create the ontology and attach to parent
                    item = populateOntology(ind.asOWLNamedIndividual(), closure);
                    item.addRegistryContentListener(this);
                    // We don't know where to attach it within this method.
                    break;
                default:
                    break;
            }
        }
        try {
            reg.addRegistryContentListener(this);
            log.info("Registry {} added.", reg.getIRI());
            population.put(reg.getIRI(), reg);
        } catch (Exception e) {
            log.error("Invalid identifier for library item " + reg, e);
            return null;
        }
        return reg;
View Full Code Here


        OWLOntology oReg = virginOntologyManager.loadOntology(Locations._REGISTRY_TEST);
        Set<Registry> rs = regman.createModel(Collections.singleton(oReg));

        // There has to be a single registry, with the expected number of children.
        assertEquals(1, rs.size());
        Registry r = rs.iterator().next();
        assertTrue(r.hasChildren());
        // The nonexistent library should also be included, if using the more powerful algorithm.
        int count = 3; // set to 2 if using the less powerful algorithm.
        assertEquals(count, r.getChildren().length);
        // There are no libraries without ontologies in the test registry.
        for (RegistryItem ri : r.getChildren())
            assertTrue(ri.hasChildren());
    }
View Full Code Here

        OWLOntology oReg = virginOntologyManager.loadOntology(Locations._REGISTRY_TEST_LOOP);
        Set<Registry> rs = regman.createModel(Collections.singleton(oReg));

        // There has to be a single registry, with the expected number of children (one).
        assertEquals(1, rs.size());
        Registry r = rs.iterator().next();
        assertTrue(r.hasChildren());
        int count = 1;
        assertEquals(count, r.getChildren().length);
        // There are no libreries without ontologies in the test registry.
        for (RegistryItem child : r.getChildren()) {
            assertTrue(child instanceof Library);
            // Check both parent-child relations.
            assertTrue(child.hasChildren());
            for (RegistryItem grandchild : child.getChildren()) {
                assertTrue(grandchild instanceof RegistryOntology);
View Full Code Here

        OntologyProvider<?> cache = it.next().getCache();
        while (it.hasNext())
            assertSame(cache, it.next().getCache());

        // Now "touch" a library.
        Registry reg;
        do
            reg = regman.getRegistries().iterator().next();
        while (!reg.hasChildren());
        assertNotNull(reg);

        // There has to be at least one non-empty lib from the test ontologies.
        Library lib = null;
        RegistryItem[] children = reg.getChildren();
        for (int i = 0; i < children.length && lib == null; i++)
            if (children[i] instanceof Library) lib = (Library) (children[i]);
        assertNotNull(lib);

        // Touch the library. Also test that the listener system works.
View Full Code Here

        regman = new RegistryManagerImpl(offline, provider, configuration);
        // Check that the configuration was set.
        assertNotNull(regman);

        // Now pick a library.
        Registry reg;
        do
            reg = regman.getRegistries().iterator().next();
        while (!reg.hasChildren());
        assertNotNull(reg);

        // There has to be at least one non-empty library from the test registries...
        Library lib = null;
        RegistryItem[] children = reg.getChildren();
        for (int i = 0; i < children.length && lib == null; i++)
            if (children[i] instanceof Library) lib = (Library) (children[i]);
        assertNotNull(lib);
        // ...and its ontologies must already be loaded without having to request them.
        assertTrue(lib.isLoaded());
View Full Code Here

        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();
        do
            reg = it.next();
        // We need a registry with at least 2 libraries to check that only one will be loaded.
        while (it.hasNext() && !reg.hasChildren() || reg.getChildren().length < 2);
        assertNotNull(reg);

        // There has to be at least one library with 2 children or more from the test registries...
        Library lib1 = null, lib2 = null;
        RegistryItem[] children = reg.getChildren();
        assertTrue(children.length >= 2);
        for (int i = 0; i < children.length - 1 && lib1 == null && lib2 == null; i++) {
            if (children[i] instanceof Library) lib1 = (Library) (children[i]);
            if (children[i + 1] instanceof Library) lib2 = (Library) (children[i + 1]);
        }
View Full Code Here

        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;
            }
        }
View Full Code Here

        OWLOntology oReg = virginOntologyManager.loadOntology(Locations._REGISTRY_TEST);
        Set<Registry> rs = regman.createModel(Collections.singleton(oReg));

        // There has to be a single registry, with the expected number of children.
        assertEquals(1, rs.size());
        Registry r = rs.iterator().next();
        assertTrue(r.hasChildren());
        // The nonexistent library should also be included, if using the more powerful algorithm.
        int count = 3; // set to 2 if using the less powerful algorithm.
        assertEquals(count, r.getChildren().length);
        // There are no libraries without ontologies in the test registry.
        for (RegistryItem ri : r.getChildren())
            assertTrue(ri.hasChildren());
    }
View Full Code Here

        OWLOntology oReg = virginOntologyManager.loadOntology(Locations._REGISTRY_TEST_LOOP);
        Set<Registry> rs = regman.createModel(Collections.singleton(oReg));

        // There has to be a single registry, with the expected number of children (one).
        assertEquals(1, rs.size());
        Registry r = rs.iterator().next();
        assertTrue(r.hasChildren());
        int count = 1;
        assertEquals(count, r.getChildren().length);
        // There are no libreries without ontologies in the test registry.
        for (RegistryItem child : r.getChildren()) {
            assertTrue(child instanceof Library);
            // Check both parent-child relations.
            assertTrue(child.hasChildren());
            for (RegistryItem grandchild : child.getChildren()) {
                assertTrue(grandchild instanceof RegistryOntology);
View Full Code Here

        OntologyProvider<?> cache = it.next().getCache();
        while (it.hasNext())
            assertSame(cache, it.next().getCache());

        // Now "touch" a library.
        Registry reg;
        do
            reg = regman.getRegistries().iterator().next();
        while (!reg.hasChildren());
        assertNotNull(reg);

        // There has to be at least one non-empty lib from the test ontologies.
        Library lib = null;
        RegistryItem[] children = reg.getChildren();
        for (int i = 0; i < children.length && lib == null; i++)
            if (children[i] instanceof Library) lib = (Library) (children[i]);
        assertNotNull(lib);

        // Touch the library. Also test that the listener system works.
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.registry.api.model.Registry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.