Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntologyManager


    public static void checkAnnotationCardinality(
            @Nonnull OWLOntology ontology,
            @Nullable AnnotationCardinalityReporter reporter,
            @Nullable AnnotationCardinalityConfictHandler handler)
            throws AnnotationCardinalityException {
        OWLOntologyManager manager = ontology.getOWLOntologyManager();
        OWLDataFactory factory = manager.getOWLDataFactory();
        Set<OWLAnnotationProperty> headerProperties = getProperties(factory,
                OboFormatTag.TAG_ONTOLOGY, OboFormatTag.TAG_FORMAT_VERSION,
                OboFormatTag.TAG_DATE, OboFormatTag.TAG_DEFAULT_NAMESPACE,
                OboFormatTag.TAG_SAVED_BY, OboFormatTag.TAG_AUTO_GENERATED_BY);
        checkOntologyAnnotations(headerProperties, ontology, reporter, handler,
View Full Code Here


    @Test
    public void testWriteReadConvertedOWL() throws Exception {
        OBODoc oboDoc = parseOBOFile("namespace-id-rule.obo");
        OWLOntology owlOntology = convert(oboDoc);
        OWLOntologyManager manager = owlOntology.getOWLOntologyManager();
        StringDocumentTarget documentTarget = new StringDocumentTarget();
        manager.saveOntology(owlOntology, new OWLXMLDocumentFormat(),
                documentTarget);
        String owlString = documentTarget.toString();
        OWLOntologyDocumentSource documentSource = new StringDocumentSource(
                owlString);
        OWLOntology reloadedOwl = OWLManager.createOWLOntologyManager()
View Full Code Here

@SuppressWarnings({ "javadoc", "null" })
public class GetLoadedOntologyTest {

    @Test
    public void testConvert() throws Exception {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        String input = "Prefix(:=<http://www.example.org/#>)\nOntology(<http://example.org/>\nSubClassOf(:a :b) )";
        StringDocumentSource source = new StringDocumentSource(input);
        OWLOntology origOnt = manager.loadOntologyFromOntologyDocument(source);
        assertNotNull(origOnt);
        assertEquals(1, manager.getOntologies().size());
        assertFalse(origOnt.getOntologyID().getVersionIRI().isPresent());
        assertTrue(origOnt.getAxiomCount() > 0);
        Optional<IRI> ontologyIRI = origOnt.getOntologyID().getOntologyIRI();
        assertTrue(ontologyIRI.isPresent());
        OWLOntology newOnt = manager.getOntology(ontologyIRI.get());
        assertNotNull(newOnt);
    }
View Full Code Here

     *
     * @return The new manager.
     */
    @Nonnull
    public static OWLOntologyManager createOWLOntologyManager() {
        OWLOntologyManager instance = INJECTOR
                .getInstance(OWLOntologyManager.class);
        INJECTOR.injectMembers(instance);
        return verifyNotNull(instance);
    }
View Full Code Here

    }

    @Test
    public void testCreateOntologyChangeEquals()
            throws OWLOntologyCreationException {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = manager.createOntology();
        OWLOntologyID ontologyID = ontology.getOntologyID();
        AddAxiomData addAxiomData = new AddAxiomData(mockAxiom);
        OWLOntologyChangeRecord changeRecord = new OWLOntologyChangeRecord(
                ontologyID, addAxiomData);
        OWLOntologyChange change = changeRecord.createOntologyChange(manager);
View Full Code Here

                KOALA));
    }

    @Test
    public void testOntologyLoading() throws OWLException {
        OWLOntologyManager m = create();
        OWLOntology o = loadPizzaOntology(m);
        assertNotNull(o);
    }
View Full Code Here

        assertNotNull(o);
    }

    @Test
    public void testOntologyLoadingFromStringSource() throws OWLException {
        OWLOntologyManager m = create();
        OWLOntology o = loadPizzaOntology(m);
        assertNotNull(o);
        // save an ontology to a document target which holds all data in memory
        StringDocumentTarget target = new StringDocumentTarget();
        m.saveOntology(o, target);
        // remove the ontology from the manager, so it can be loaded again
        m.removeOntology(o);
        // create a document source from a string
        StringDocumentSource documentSource = new StringDocumentSource(target);
        // load the ontology from a document source
        OWLOntology o2 = m.loadOntologyFromOntologyDocument(documentSource);
        assertNotNull(o2);
    }
View Full Code Here

        assertNotNull(o2);
    }

    @Test
    public void testOntologyCreation() throws OWLException {
        OWLOntologyManager m = create();
        OWLOntology o = m.createOntology(EXAMPLE_IRI);
        assertNotNull(o);
    }
View Full Code Here

        assertNotNull(o);
    }

    @Test
    public void testShowClasses() throws OWLException {
        OWLOntologyManager m = create();
        OWLOntology o = loadPizzaOntology(m);
        assertNotNull(o);
        // These are the named classes referenced by axioms in the ontology.
        for (OWLClass cls : o.getClassesInSignature()) {
            // use the class for whatever purpose
View Full Code Here

    @Nonnull
    OWLPropertyExpression[] owlpropertyexpression = {};

    @Test
    public void testrun() throws Exception {
        OWLOntologyManager m = OWLManager.createOWLOntologyManager();
        m.getIRIMappers().add(new AutoIRIMapper(new File("."), false));
        OWLOntology o = m.loadOntologyFromOntologyDocument(getClass()
                .getResourceAsStream("/pizza.owl"));
        m.addAxiom(o, DF.getOWLDeclarationAxiom(DF.getOWLClass(iri)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLClass(string, prefixmanager)));
        m.addAxiom(o, DF.getOWLEquivalentClassesAxiom(DF.getOWLClass(iri), c));
        m.addAxiom(o, DF.getOWLDisjointClassesAxiom(DF.getOWLClass(iri), c));
        m.addAxiom(o, DF.getOWLSubObjectPropertyOfAxiom(op, op));
        m.addAxiom(o, DF.getOWLSubPropertyChainOfAxiom(
                listowlobjectpropertyexpression, op));
        m.addAxiom(o, DF.getOWLEquivalentObjectPropertiesAxiom(setop));
        m.addAxiom(o, DF.getOWLDisjointObjectPropertiesAxiom(setop));
        m.addAxiom(o, DF.getOWLInverseObjectPropertiesAxiom(op, op));
        m.addAxiom(o, DF.getOWLObjectPropertyDomainAxiom(op, c));
        m.addAxiom(o, DF.getOWLObjectPropertyRangeAxiom(op, c));
        m.addAxiom(o, DF.getOWLFunctionalObjectPropertyAxiom(op));
        m.addAxiom(o,
                DF.getOWLAnnotationAssertionAxiom(ap, as, owlannotationvalue));
        m.applyChange(new AddImport(o, DF.getOWLImportsDeclaration(iri)));
        m.addAxiom(o, DF.getOWLAnnotationPropertyDomainAxiom(ap, iri));
        m.addAxiom(o, DF.getOWLAnnotationPropertyRangeAxiom(ap, iri));
        m.addAxiom(o, DF.getOWLSubAnnotationPropertyOfAxiom(ap, ap));
        m.addAxiom(o, DF.getOWLInverseFunctionalObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLReflexiveObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLIrreflexiveObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLSymmetricObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLAsymmetricObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLTransitiveObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLSubDataPropertyOfAxiom(dp, dp));
        m.addAxiom(o, DF.getOWLEquivalentDataPropertiesAxiom(setdp));
        m.addAxiom(o, DF.getOWLDisjointDataPropertiesAxiom(setdp));
        m.addAxiom(o, DF.getOWLDataPropertyDomainAxiom(dp, c));
        m.addAxiom(o, DF.getOWLDataPropertyRangeAxiom(dp, dr));
        m.addAxiom(o, DF.getOWLFunctionalDataPropertyAxiom(dp));
        m.addAxiom(o, DF.getOWLHasKeyAxiom(c, setowlpropertyexpression));
        m.addAxiom(o, DF.getOWLDatatypeDefinitionAxiom(owldatatype, dr));
        m.addAxiom(o, DF.getOWLSameIndividualAxiom(setowlindividual));
        m.addAxiom(o, DF.getOWLDifferentIndividualsAxiom(setowlindividual));
        m.addAxiom(o, DF.getOWLClassAssertionAxiom(c, ai));
        m.addAxiom(o, DF.getOWLObjectPropertyAssertionAxiom(op, ai, ai));
        m.addAxiom(o, DF.getOWLNegativeObjectPropertyAssertionAxiom(op, ai, ai));
        m.addAxiom(o, DF.getOWLDataPropertyAssertionAxiom(dp, ai, owlliteral));
        m.addAxiom(o,
                DF.getOWLNegativeDataPropertyAssertionAxiom(dp, ai, owlliteral));
        m.addAxiom(
                o,
                DF.getOWLInverseObjectPropertiesAxiom(op,
                        DF.getOWLObjectInverseOf(op)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLDataExactCardinality(1, dp)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLDataMaxCardinality(1, dp)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLDataMinCardinality(1, dp)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectExactCardinality(1, op)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectMaxCardinality(1, op)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectMinCardinality(1, op)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(dp,
                        DF.getOWLDatatype(string, prefixmanager)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyAssertionAxiom(dp, ai,
                        DF.getOWLLiteral(string, owldatatype)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(dp,
                        DF.getOWLDataOneOf(owlliteral)));
        m.addAxiom(o,
                DF.getOWLDataPropertyRangeAxiom(dp, DF.getOWLDataUnionOf(dr)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(dp,
                        DF.getOWLDataIntersectionOf(dr)));
        m.addAxiom(o,
                DF.getOWLDataPropertyRangeAxiom(dp, DF
                        .getOWLDatatypeRestriction(owldatatype, owlfacet,
                                owlliteral)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(
                        dp,
                        DF.getOWLDatatypeRestriction(owldatatype,
                                DF.getOWLFacetRestriction(owlfacet, 1))));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(
                        c,
                        DF.getOWLObjectIntersectionOf(c,
                                DF.getOWLClass(string, prefixmanager))));
        m.addAxiom(o, DF.getOWLSubClassOfAxiom(c,
                DF.getOWLDataSomeValuesFrom(dp, dr)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLDataAllValuesFrom(dp, dr)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLDataHasValue(dp, owlliteral)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectComplementOf(DF.getOWLClass(iri))));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectOneOf(DF.getOWLNamedIndividual(iri))));
        m.addAxiom(o, DF.getOWLSubClassOfAxiom(c,
                DF.getOWLObjectAllValuesFrom(op, c)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectSomeValuesFrom(op, c)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLObjectHasValue(op, ai)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectUnionOf(DF.getOWLClass(iri))));
        m.addAxiom(
                o,
                DF.getOWLAnnotationAssertionAxiom(iri,
                        DF.getOWLAnnotation(ap, owlannotationvalue)));
        m.addAxiom(o, DF.getOWLAnnotationAssertionAxiom(DF
                .getOWLNamedIndividual(iri).getIRI(), DF.getOWLAnnotation(ap,
                owlannotationvalue)));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream stream = new ObjectOutputStream(out);
        stream.writeObject(m);
        stream.flush();
        // System.out.println(out.toString());
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        ObjectInputStream inStream = new ObjectInputStream(in);
        OWLOntologyManager copy = (OWLOntologyManager) inStream.readObject();
        for (OWLOntology onto : copy.getOntologies()) {
            OWLOntology original = m.getOntology(onto.getOntologyID()
                    .getOntologyIRI().get());
            assertEquals("Troubles with ontology " + onto.getOntologyID(),
                    original.getAxioms(), onto.getAxioms());
        }
View Full Code Here

TOP

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

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.