Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntology


        equal(func, owl);
    }

    @Test
    public void shouldTURTLEBeEquivalent() {
        OWLOntology turt = loadOntologyFromString(TURTLE,
                IRI.create("urn:primer#turtle"), new TurtleDocumentFormat());
        assertTrue(profile.checkOntology(turt).getViolations().isEmpty());
        // XXX somehow the Turtle parser introduces a tautology: the inverse of
        // inverse(hasParent) is hasParent
        // dropping said tautology to assert equality of the rest of the axioms
        OWLObjectProperty hasParent = df.getOWLObjectProperty(IRI
                .create("http://example.com/owl/families/hasParent"));
        turt.getOWLOntologyManager().removeAxiom(
                turt,
                df.getOWLInverseObjectPropertiesAxiom(
                        df.getOWLObjectInverseOf(hasParent), hasParent));
        equal(func, turt);
    }
View Full Code Here


     * @throws OWLOntologyCreationException
     *         exception
     */
    @Test
    public void testImportsClosure() throws OWLOntologyCreationException {
        OWLOntology ontA = m.createOntology(OWLOntologyDocumentSourceBase
                .getNextDocumentIRI("urn:testontology"));
        OWLOntology ontB = m.createOntology(OWLOntologyDocumentSourceBase
                .getNextDocumentIRI("urn:testontology"));
        assertTrue(m.getImportsClosure(ontA).contains(ontA));
        @SuppressWarnings("null")
        OWLImportsDeclaration importsDeclaration = ImportsDeclaration(ontB
                .getOntologyID().getOntologyIRI().get());
        m.applyChange(new AddImport(ontA, importsDeclaration));
        assertTrue(m.getImportsClosure(ontA).contains(ontB));
        m.applyChange(new RemoveImport(ontA, importsDeclaration));
        assertFalse(m.getImportsClosure(ontA).contains(ontB));
View Full Code Here

public abstract class AbstractAxiomsRoundTrippingTestCase extends
        AbstractRoundTrippingTestCase {

    @Override
    protected OWLOntology createOntology() {
        OWLOntology ont = getOWLOntology("Ont");
        ont.getOWLOntologyManager().addAxioms(ont, createAxioms());
        for (OWLEntity entity : ont.getSignature()) {
            if (!entity.isBuiltIn() && !ont.isDeclared(entity, INCLUDED)) {
                ont.getOWLOntologyManager().addAxiom(ont, Declaration(entity));
            }
        }
        return ont;
    }
View Full Code Here

    }

    private void roundTrip(@Nonnull OWLDocumentFormat ontologyFormat)
            throws OWLOntologyCreationException, OWLOntologyStorageException {
        OWLOntologyManager man = OWLManager.createOWLOntologyManager();
        OWLOntology ont = man.createOntology();
        man.addAxiom(ont, rule);
        StringDocumentTarget documentTarget = new StringDocumentTarget();
        man.saveOntology(ont, ontologyFormat, documentTarget);
        OWLOntologyManager man2 = OWLManager.createOWLOntologyManager();
        OWLOntology ont2 = man2
                .loadOntologyFromOntologyDocument(new StringDocumentSource(
                        documentTarget.toString(),
                        OWLOntologyDocumentSourceBase
                                .getNextDocumentIRI("string:ontology"),
                        ontologyFormat, null));
        Set<SWRLRule> rules = ont2.getAxioms(AxiomType.SWRL_RULE);
        assertThat(rules.size(), is(1));
        SWRLRule parsedRule = rules.iterator().next();
        assertThat(parsedRule, is(equalTo(rule)));
        List<SWRLAtom> originalBody = new ArrayList<>(body);
        List<SWRLAtom> parsedBody = new ArrayList<>(parsedRule.getBody());
View Full Code Here

    @Override
    public OWLOntology getOntology(IRI ontologyIRI) {
        OWLOntologyID ontologyID = new OWLOntologyID(of(ontologyIRI),
                of((IRI) null));
        OWLOntology result = ontologiesByID.get(ontologyID);
        if (result == null) {
            for (OWLOntologyID nextOntologyID : ontologiesByID.keySet()) {
                if (ontologyIRI.equals(nextOntologyID.getVersionIRI().orNull())
                        || ontologyIRI.equals(nextOntologyID.getOntologyIRI()
                                .orNull())
View Full Code Here

        return first.getOntologyIRI().equals(second.getOntologyIRI());
    }

    @Override
    public OWLOntology getOntology(OWLOntologyID ontologyID) {
        OWLOntology result = ontologiesByID.get(ontologyID);
        if (result == null && !ontologyID.isAnonymous()) {
            for (OWLOntologyID nextOntologyID : ontologiesByID.keySet()) {
                if (matchingIDs(ontologyID, nextOntologyID)) {
                    result = ontologiesByID.get(nextOntologyID);
                }
View Full Code Here

            throw new UnknownOWLOntologyException(ontology.getOntologyID());
        }
        Set<OWLOntology> imports = new HashSet<>();
        for (OWLImportsDeclaration axiom : ontology.getImportsDeclarations()) {
            assert axiom != null;
            OWLOntology importedOntology = getImportedOntology(axiom);
            if (importedOntology != null) {
                imports.add(importedOntology);
            }
        }
        return imports;
View Full Code Here

    private List<OWLOntologyChange> enactChangeApplication(
            OWLOntologyChange change) {
        if (!isChangeApplicable(change)) {
            return Collections.emptyList();
        }
        OWLOntology ont = change.getOntology();
        if (!(ont instanceof OWLMutableOntology)) {
            throw new ImmutableOWLOntologyChangeException(
                    change.getChangeData(), ont.toString());
        }
        checkForOntologyIDChange(change);
        ChangeApplied appliedChange = ((OWLMutableOntology) ont)
                .applyChange(change);
        checkForImportsChange(change);
View Full Code Here

    }

    private void checkForOntologyIDChange(OWLOntologyChange change) {
        if (change instanceof SetOntologyID) {
            SetOntologyID setID = (SetOntologyID) change;
            OWLOntology existingOntology = ontologiesByID
                    .get(((SetOntologyID) change).getNewOntologyID());
            if (existingOntology != null
                    && !change.getOntology().equals(existingOntology)) {
                if (!change.getOntology().getAxioms()
                        .equals(existingOntology.getAxioms())) {
                    LOGGER.error(
                            "OWLOntologyManagerImpl.checkForOntologyIDChange() existing:{}",
                            existingOntology);
                    LOGGER.error(
                            "OWLOntologyManagerImpl.checkForOntologyIDChange() new:{}",
View Full Code Here

    }

    @Override
    public OWLOntology createOntology(@Nonnull OWLOntologyID ontologyID)
            throws OWLOntologyCreationException {
        OWLOntology ontology = ontologiesByID.get(ontologyID);
        if (ontology != null) {
            throw new OWLOntologyAlreadyExistsException(ontologyID);
        }
        IRI documentIRI = getDocumentIRIFromMappers(ontologyID, true);
        if (documentIRI == null) {
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.