Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntology


    @Nonnull
    private OWLOntology createOntology(@Nonnull OWLAnnotationProperty p)
            throws OWLOntologyCreationException {
        OWLClass a = Class(IRI("http://test.org/MissingDeclaration.owl#A"));
        OWLOntology ontology = m.createOntology();
        OWLAxiom axiom = AnnotationAssertion(p, a.getIRI(), Literal("Hello"));
        m.addAxiom(ontology, axiom);
        return ontology;
    }
View Full Code Here


            + "            <rdfs:Datatype rdf:about=\"http://www.w3.org/2001/XMLSchema#double\"/>\n"
            + "        </owl:annotatedTarget>\n" + "    </owl:Axiom></rdf:RDF>";

    @Test
    public void testMove() throws OWLOntologyCreationException {
        OWLOntology o = loadOntologyFromString(s);
        OWLOntologyManager m2 = o.getOWLOntologyManager();
        OWLOntology copy = m1.copyOntology(o, OntologyCopy.MOVE);
        assertSame(o, copy);
        assertEquals(m1, copy.getOWLOntologyManager());
        assertFalse(m2.contains(o));
        assertTrue(m1.contains(copy));
        assertNull(m2.getOntologyFormat(o));
    }
View Full Code Here

        assertNull(m2.getOntologyFormat(o));
    }

    @Test
    public void testShallow() throws OWLOntologyCreationException {
        OWLOntology o = loadOntologyFromString(s);
        OWLOntologyManager m2 = o.getOWLOntologyManager();
        OWLOntology copy = m1.copyOntology(o, OntologyCopy.SHALLOW);
        assertEquals(m1, copy.getOWLOntologyManager());
        assertTrue(m2.contains(o));
        assertTrue(m1.contains(copy));
        assertNotNull(m2.getOntologyFormat(o));
    }
View Full Code Here

        assertNotNull(m2.getOntologyFormat(o));
    }

    @Test
    public void testDeep() throws OWLOntologyCreationException {
        OWLOntology o = loadOntologyFromString(s);
        OWLOntologyManager m2 = o.getOWLOntologyManager();
        OWLOntology copy = m1.copyOntology(o, OntologyCopy.DEEP);
        assertEquals(m1, copy.getOWLOntologyManager());
        assertTrue(m2.contains(o));
        assertTrue(m1.contains(copy));
        assertNotNull(m2.getOntologyFormat(o));
        assertNotNull(m1.getOntologyFormat(o));
    }
View Full Code Here

        manager.getIRIMappers().add(new NonMappingOntologyIRIMapper());
    }

    @Test
    public void testContains() throws OWLOntologyCreationException {
        OWLOntology ont = manager.createOntology(OWLOntologyDocumentSourceBase
                .getNextDocumentIRI("urn:testontology"));
        assertTrue(manager.contains(ont.getOntologyID()));
        assertNotNull("ontology should not be null",
                manager.getOntology(ont.getOntologyID()));
        assertTrue(manager.getOntologies().contains(ont));
        assertNotNull("IRI should not be null",
                manager.getOntologyDocumentIRI(ont));
        manager.removeOntology(ont);
        assertFalse(manager.contains(ont.getOntologyID()));
    }
View Full Code Here

        assertFalse(manager.contains(ont.getOntologyID()));
    }

    @Test
    public void testImports() throws OWLOntologyCreationException {
        OWLOntology ontA = manager.createOntology(OWLOntologyDocumentSourceBase
                .getNextDocumentIRI("urn:testontology"));
        OWLOntology ontB = manager.createOntology(OWLOntologyDocumentSourceBase
                .getNextDocumentIRI("urn:testontology"));
        OWLImportsDeclaration decl = manager.getOWLDataFactory()
                .getOWLImportsDeclaration(
                        ontB.getOntologyID().getOntologyIRI().get());
        manager.applyChange(new AddImport(ontA, decl));
        assertTrue(manager.getDirectImports(ontA).contains(ontB));
        manager.removeOntology(ontB);
        assertFalse(manager.getDirectImports(ontA).contains(ontB));
    }
View Full Code Here

        assertTrue(profile.checkOntology(func).isInProfile());
    }

    @Test
    public void shouldManchBeEquivalent() throws OWLOntologyCreationException {
        OWLOntology manch = loadOntologyFromString(MANCHESTER,
                IRI.create("urn:primer#manchester"),
                new ManchesterSyntaxDocumentFormat());
        assertTrue(profile.checkOntology(manch).getViolations().isEmpty());
        // XXX Manchester OWL Syntax does not support GCIs
        // the input adopts a trick to semantically get around this, by
        // asserting a new named class equivalent to the right hand side of the
        // GCI and subclass of the left hand side
        // Rectifying this to be able to assert equality, and using a different
        // ontology
        // so that the equality test does not skip gcis because of the format
        OWLClass x = df.getOWLClass(IRI
                .create("http://example.com/owl/families/X"));
        Set<OWLClassAxiom> axioms = manch.getAxioms(x, EXCLUDED);
        manch.getOWLOntologyManager().removeAxioms(manch, axioms);
        OWLClass female = df.getOWLClass(IRI
                .create("http://example.com/owl/families/Female"));
        OWLClassExpression oneOf = df.getOWLObjectOneOf(df
                .getOWLNamedIndividual(IRI
                        .create("http://example.com/owl/families/Bill")), df
                .getOWLNamedIndividual(IRI
                        .create("http://example.com/owl/families/Mary")), df
                .getOWLNamedIndividual(IRI
                        .create("http://example.com/owl/families/Meg")));
        OWLClass parent = df.getOWLClass(IRI
                .create("http://example.com/owl/families/Parent"));
        OWLObjectProperty hasChild = df.getOWLObjectProperty(IRI
                .create("http://example.com/owl/families/hasChild"));
        OWLClassExpression superClass = df.getOWLObjectIntersectionOf(parent,
                df.getOWLObjectAllValuesFrom(hasChild, female),
                df.getOWLObjectMaxCardinality(1, hasChild));
        manch.getOWLOntologyManager().addAxiom(
                manch,
                df.getOWLSubClassOfAxiom(
                        df.getOWLObjectIntersectionOf(female, oneOf),
                        superClass));
        OWLOntology replacement = OWLManager.createOWLOntologyManager()
                .createOntology(manch.getAxioms(),
                        manch.getOntologyID().getOntologyIRI().get());
        equal(func, replacement);
    }
View Full Code Here

        assertEquals(1, b.getImports().size());
    }

    private OWLOntology createOntologyFile(@Nonnull IRI iri, @Nonnull File f)
            throws Exception {
        OWLOntology a = m1.createOntology(iri);
        OutputStream out = new FileOutputStream(f);
        m1.saveOntology(a, out);
        out.close();
        return a;
    }
View Full Code Here

        equal(func, replacement);
    }

    @Test
    public void shouldRDFXMLBeEquivalent() {
        OWLOntology rdf = loadOntologyFromString(RDFXML,
                IRI.create("urn:primer#rdfxml"), new RDFXMLDocumentFormat());
        assertTrue(profile.checkOntology(rdf).getViolations().isEmpty());
        equal(func, rdf);
    }
View Full Code Here

        equal(func, rdf);
    }

    @Test
    public void shouldOWLXMLBeEquivalent() {
        OWLOntology owl = loadOntologyFromString(OWLXML,
                IRI.create("urn:primer#owlxml"), new OWLXMLDocumentFormat());
        assertTrue(profile.checkOntology(owl).getViolations().isEmpty());
        equal(func, owl);
    }
View Full Code Here

TOP

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

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.