Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntologyID


        if (it.hasNext()) {
            Resource obj = it.next().getObject();
            if (obj instanceof UriRef) viri = IRI.create(((UriRef) obj).getUnicodeString());
            else if (obj instanceof Literal) viri = IRI.create(((Literal) obj).getLexicalForm());
        }
        if (viri == null) return new OWLOntologyID(oiri);
        else return new OWLOntologyID(oiri, viri);
    }
View Full Code Here


    @Test
    public void storedOntologyOutlivesScope() throws Exception {
        String ephemeralScopeId = "CaducousScope";
        OntologyInputSource<OWLOntology> ois = new RootOntologySource(IRI.create(getClass().getResource(
            "/ontologies/nonexistentcharacters.owl")));
        OWLOntologyID ontologyId = ois.getRootOntology().getOntologyID();
        Scope scope = onManager.createOntologyScope(ephemeralScopeId);
        // Initially, the ontology is not there
        assertFalse(ontologyProvider.hasOntology(ontologyId));
        // Once added, the ontology is there
        scope.getCustomSpace().addOntology(ois);
View Full Code Here

    // @Test
    public void zombieSessionClearsContents() throws Exception {
        Session ses = sessionManager.createSession();
        ses.addOntology(new RootOntologySource((IRI
                .create(getClass().getResource("/ontologies/mockfoaf.rdf")))));
        OWLOntologyID expectedKey = new OWLOntologyID(IRI.create("http://xmlns.com/foaf/0.1/"));
        assertTrue(ontologyProvider.hasOntology(expectedKey));
        sessionManager.destroySession(ses.getID());
    }
View Full Code Here

    @Test
    public void testVersionIRISplit() throws Exception {

        // Check the first version
        InputStream data = getClass().getResourceAsStream(fn1);
        OWLOntologyID key1 = ontologyProvider.loadInStore(data, RDF_XML, true);
        assertNotNull(key1);
        assertFalse(key1.isAnonymous());

        // Check the second version
        data = getClass().getResourceAsStream(fn2);
        OWLOntologyID key2 = ontologyProvider.loadInStore(data, RDF_XML, true);
        assertNotNull(key2);
        assertFalse(key2.isAnonymous());

        // Must be 2 different graphs
        assertFalse(key1.equals(key2));
        assertEquals(2, ontologyProvider.listPrimaryKeys().size());
View Full Code Here

    @Test
    public void testAddOntology() throws Exception {
        OntologySpace space = null;

        OWLOntologyID logicalId = OWLUtils.extractOntologyID(nonexSrc.getRootOntology());
        assertNotNull(logicalId);

        space = factory.createCustomOntologySpace(scopeId, dropSrc, minorSrc);
        space.addOntology(minorSrc);
        space.addOntology(nonexSrc);
View Full Code Here

    }

    @Test
    public void testCreateSpace() throws Exception {
        OntologySpace space = factory.createCustomOntologySpace(scopeId, dropSrc);
        OWLOntologyID logicalId = null;
        Object o = dropSrc.getRootOntology();
        if (o instanceof TripleCollection) logicalId = OWLUtils.extractOntologyID((TripleCollection) o);
        else if (o instanceof OWLOntology) logicalId = OWLUtils.extractOntologyID((OWLOntology) o);
        assertNotNull(logicalId);
        assertTrue(space.hasOntology(logicalId));
View Full Code Here

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

    private TcProvider tcp;

    @Test
    public void canRetrieveOntologyImported() throws Exception {
        String pcomics = "http://stanbol.apache.org/ontologies/pcomics/";
        OWLOntologyID foaf = new OWLOntologyID(IRI.create("http://xmlns.com/foaf/0.1/")), all = new OWLOntologyID(
                IRI.create(pcomics + "characters_all.owl")), main = new OWLOntologyID(
                IRI.create(pcomics + "maincharacters.owl")), minor = new OWLOntologyID(
                IRI.create(pcomics + "minorcharacters.owl"));
        OWLOntology oAll, oMain, oMinor, oFoaf;
        final int total = 4;

        // Load the Peanuts characters_all ontology (has 2 import levels)
        InputStream data = getClass().getResourceAsStream("/ontologies/characters_all.owl");
        OWLOntologyID key = ontologyProvider.loadInStore(data, SupportedFormat.RDF_XML, false);
        assertNotNull(key);
        assertFalse(key.isAnonymous());

        /*
         * characters_all, main, minor + mockfoaf (note: imports are available only because the xml:base is
         * set to be the same as the import target)
         */
        assertEquals(total, ontologyProvider.listPrimaryKeys().size());

        // Check that each imported ontology is stored
        oAll = ontologyProvider.getStoredOntology(all, OWLOntology.class, false);
        OWLOntologyID id = oAll.getOntologyID();
        assertNotNull(id);
        assertEquals(all, id);
        oMain = ontologyProvider.getStoredOntology(main, OWLOntology.class, false);
        id = oMain.getOntologyID();
        assertNotNull(id);
View Full Code Here

    }

    @Test
    public void canRetrieveOntologySingleton() throws Exception {

        OWLOntologyID foaf = new OWLOntologyID(IRI.create("http://xmlns.com/foaf/0.1/"));
        OWLOntology o1;

        // Get the fake FOAF and load it into the ontology provider
        InputStream data = getClass().getResourceAsStream("/ontologies/mockfoaf.rdf");
        // Keep track of its storage key
        OWLOntologyID key = ontologyProvider.loadInStore(data, SupportedFormat.RDF_XML, false);
        assertNotNull(key);
        assertFalse(key.isAnonymous());

        // Retrieve the stored fake FOAF
        assertEquals(1, ontologyProvider.listPrimaryKeys().size());
        o1 = ontologyProvider.getStoredOntology(key, OWLOntology.class, false);
        OWLOntologyID id = o1.getOntologyID();
        assertNotNull(id);
        assertEquals(foaf, id);

        // Check there is a storage key for the (real) ID of the FOAF ontology
        // key = ontologyProvider.getKey(foaf);
View Full Code Here

        String[] split = stringForm.split(":::");
        if (split.length >= 1) {
            oiri = URIUtils.desanitize(IRI.create(split[0].replace("%3A%3A%3A", ":::")));
            viri = (split.length > 1) ? URIUtils.desanitize(IRI.create(split[1].replace("%3A%3A%3A", ":::")))
                    : null;
            return (viri != null) ? new OWLOntologyID(oiri, viri) : new OWLOntologyID(oiri);
        } else return null; // Anonymous but versioned ontologies are not acceptable.
    }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLOntologyID

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.