Examples of OntologySpace


Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

        assertNotNull(shouldBeNotNull);
    }

    @Test
    public void testRemoveCustomOntology() throws Exception {
        OntologySpace space = null;
        space = factory.createCustomOntologySpace(scopeId, dropSrc);
        OWLOntologyID dropId = OWLUtils.extractOntologyID(dropSrc.getRootOntology());
        OWLOntologyID nonexId = OWLUtils.extractOntologyID(nonexSrc.getRootOntology());

        space.addOntology(inMemorySrc);
        space.addOntology(nonexSrc);
        // The other remote ontologies may change base IRI...
        // baseIri is maincharacters
        assertTrue(space.hasOntology(baseIri));
        assertTrue(space.hasOntology(dropId));
        assertTrue(space.hasOntology(nonexId));
        space.removeOntology(dropId);
        assertFalse(space.hasOntology(dropId));
        space.removeOntology(nonexId);
        assertFalse(space.hasOntology(nonexId));
        // OntologyUtils.printOntology(space.getTopOntology(), System.err);

    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

                Scope sc = null;
                sc = /* factory. */createOntologyScope(scopeId, new BlankOntologySource());

                // Populate the core space
                if (cores.length > 0) {
                    OntologySpace corespc = sc.getCoreSpace();
                    corespc.tearDown();
                    for (int i = 0; i < cores.length; i++)
                        try {
                            corespc.addOntology(new RootOntologySource(IRI.create(cores[i])));
                        } catch (Exception ex) {
                            log.warn("Failed to import ontology " + cores[i], ex);
                            continue;
                        }
                }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

            } catch (DuplicateIDException e) {
                String dupe = e.getDuplicateID();
                log.warn("Scope \"{}\" already exists and will be reused.", dupe);
                scope = getScope(dupe);
            }
            OntologySpace custom = scope.getCustomSpace();
            // Register even if some ontologies were to fail to be restored afterwards.
            scopeMap.put(scopeId, scope);
            for (OWLOntologyID key : struct.getCustomOntologyKeysForScope(scopeId))
                try {
                    log.debug("Custom ontology key : {}", key);
                    custom.addOntology(new StoredOntologySource(key));
                } catch (MissingOntologyException ex) {
                    log.error(
                        "Could not find an ontology with public key {} to be managed by scope \"{}\". Proceeding to next ontology.",
                        key, scopeId);
                    continue;
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

        reset();
    }

    @Test
    public void testAddOntology() throws Exception {
        OntologySpace space = null;
        IRI logicalId = nonexSrc.getRootOntology().getOntologyID().getOntologyIRI();

        space = factory.createCustomOntologySpace("testAddOntology", dropSrc);
        space.addOntology(minorSrc);
        space.addOntology(nonexSrc);

        assertTrue(space.hasOntology(logicalId));
        logicalId = dropSrc.getRootOntology().getOntologyID().getOntologyIRI();
        assertTrue(space.hasOntology(logicalId));
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

        assertTrue(space.hasOntology(logicalId));
    }

    @Test
    public void testCoreLock() throws Exception {
        OntologySpace space = factory.createCoreOntologySpace("testCoreLock", inMemorySrc);
        space.setUp();
        try {
            space.addOntology(minorSrc);
            fail("Modification was permitted on locked ontology space.");
        } catch (UnmodifiableOntologyCollectorException e) {
            assertSame(space, e.getOntologyCollector());
        }
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

        }
    }

    @Test
    public void testCreateSpace() throws Exception {
        OntologySpace space = factory.createCustomOntologySpace("testCreateSpace", dropSrc);
        IRI logicalId = dropSrc.getRootOntology().getOntologyID().getOntologyIRI();
        assertTrue(space.hasOntology(logicalId));
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

        assertTrue(space.hasOntology(logicalId));
    }

    @Test
    public void testCustomLock() throws Exception {
        OntologySpace space = factory.createCustomOntologySpace("testCustomLock", inMemorySrc);
        space.setUp();
        try {
            space.addOntology(minorSrc);
            fail("Modification was permitted on locked ontology space.");
        } catch (UnmodifiableOntologyCollectorException e) {
            assertSame(space, e.getOntologyCollector());
        }
    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

     * @throws Exception
     *             if an unexpected error occurs.
     */
    @Test
    public void testIdentifiers() throws Exception {
        OntologySpace shouldBeNull = null, shouldBeNotNull = null;

        /* First test space identifiers. */

        // Null identifier (invalid).
        try {
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

        assertNotNull(shouldBeNotNull);
    }

    @Test
    public void testRemoveCustomOntology() throws Exception {
        OntologySpace space = null;
        space = factory.createCustomOntologySpace("testRemoveCustomOntology", dropSrc);

        IRI dropId = dropSrc.getRootOntology().getOntologyID().getOntologyIRI();
        IRI nonexId = nonexSrc.getRootOntology().getOntologyID().getOntologyIRI();

        space.addOntology(inMemorySrc);
        space.addOntology(nonexSrc);
        // The other remote ontologies may change base IRI...
        assertTrue(space.hasOntology(ont.getOntologyID().getOntologyIRI()));
        assertTrue(space.hasOntology(dropId));
        assertTrue(space.hasOntology(nonexId));

        IRI bogus = IRI.create("http://www.example.org/ontology/bogus");
        try {
            space.removeOntology(bogus);
            fail("Removing nonexisting ontology succeeded without an exception. This should not happen.");
        } catch (MissingOntologyException mex) {
            log.info("Expected exception caught when removing missing ontology {}", bogus);
        }

        space.removeOntology(dropId);
        assertFalse(space.hasOntology(dropId));
        space.removeOntology(nonexId);
        assertFalse(space.hasOntology(nonexId));
        // OntologyUtils.printOntology(space.getTopOntology(), System.err);

    }
View Full Code Here

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

            } else {
                // The root ontology ID is in the form [namespace][scopeId]
                ont = mgr.createOntology(IRI.create(universalPrefix + getID()));
                List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                // Add the import statement for the custom space, if existing and not empty
                OntologySpace spc = getCustomSpace();
                if (spc != null && spc.listManagedOntologies().size() > 0) {
                    IRI spaceIri = IRI.create(universalPrefix + spc.getID());
                    additions.add(new AddImport(ont, df.getOWLImportsDeclaration(spaceIri)));
                }
                // Add the import statement for the core space, if existing and not empty
                spc = getCoreSpace();
                if (spc != null && spc.listManagedOntologies().size() > 0) {
                    IRI spaceIri = IRI.create(universalPrefix + spc.getID());
                    additions.add(new AddImport(ont, df.getOWLImportsDeclaration(spaceIri)));
                }
                mgr.applyChanges(additions);
            }
        } catch (OWLOntologyCreationException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.