Package org.semanticweb.owlapi.util

Examples of org.semanticweb.owlapi.util.AutoIRIMapper


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


    @Nonnull
    public OWLOntologyManager create() {
        OWLOntologyManager m = OWLManager.createOWLOntologyManager();
        PriorityCollection<OWLOntologyIRIMapper> iriMappers = m.getIRIMappers();
        iriMappers.add(new AutoIRIMapper(new File("materializedOntologies"),
                true));
        return m;
    }
View Full Code Here

        m.getIRIMappers().add(mapper);
        // set up a mapper to read local copies of ontologies
        File localFolder = new File("materializedOntologies");
        // the manager will look up an ontology IRI by checking
        // localFolder first for a local copy, checking its subfolders as well
        m.getIRIMappers().add(new AutoIRIMapper(localFolder, true));
        // Create the ontology - we use the ontology IRI (not the physical URI)
        OWLOntology o = m.createOntology(EXAMPLE_SAVE_IRI);
        // save the ontology to its physical location - documentIRI
        m.saveOntology(o);
        assertNotNull(o);
View Full Code Here

        }
    }

    @Test
    public void shouldTestIRIMapperForOWLXML() {
        AutoIRIMapper mapper = new AutoIRIMapper(RESOURCES, false);
        assertTrue(mapper.getDocumentIRI(IRI.create("urn:test:prem"))
                .toString().endsWith("/urntestontology.xml"));
    }
View Full Code Here

        // case we've just specified the tmp directory.
        @Nonnull
        File file = folder.newFolder();
        // We can also specify a flag to indicate whether the directory should
        // be searched recursively.
        OWLOntologyIRIMapper autoIRIMapper = new AutoIRIMapper(file, false);
        // We can now use this mapper in the usual way, i.e.
        manager2.getIRIMappers().add(autoIRIMapper);
        // Of course, applications (such as Protege) usually implement their own
        // mappers to deal with specific application requirements.
    }
View Full Code Here

    }

    @Test
    public void testImports() throws OWLOntologyCreationException {
        m.getIRIMappers().add(
                new AutoIRIMapper(new File(RESOURCES, "imports"), true));
        m.loadOntologyFromOntologyDocument(new File(RESOURCES, "/imports/D.owl"));
    }
View Full Code Here

    }

    @Test
    public void testCyclicImports() throws OWLOntologyCreationException {
        m.getIRIMappers().add(
                new AutoIRIMapper(new File(RESOURCES, "importscyclic"), true));
        m.loadOntologyFromOntologyDocument(new File(RESOURCES,
                "/importscyclic/D.owl"));
    }
View Full Code Here

    }

    @Test
    public void testCyclicImports2() throws OWLOntologyCreationException {
        m.getIRIMappers().add(
                new AutoIRIMapper(new File(RESOURCES, "importscyclic"), true));
        m.loadOntologyFromOntologyDocument(IRI.create(new File(RESOURCES,
                "importscyclic/D.owl")));
    }
View Full Code Here

        assertNotNull(manager.getOntology(IRI(str)));
    }

    private static OWLOntologyManager getManager() {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        AutoIRIMapper mapper = new AutoIRIMapper(
                new File(RESOURCES, "imports"), true);
        manager.getIRIMappers().add(mapper);
        return manager;
    }
View Full Code Here

        URL url = getClass().getResource("/ontologies");
        assertNotNull(url);
        File file = new File(url.toURI());
        assertTrue(file.exists());
        assertTrue(file.isDirectory());
        OWLOntologyIRIMapper mapper = new AutoIRIMapper(file, true);

        IRI dummyiri = IRI.create("http://stanbol.apache.org/ontologies/peanuts/dummycharacters.owl");

        // Cleanup may be required if previous tests have failed.
        if (mapper.getDocumentIRI(dummyiri) != null) {
            new File(mapper.getDocumentIRI(dummyiri).toURI()).delete();
            ((AutoIRIMapper) mapper).update();
        }
        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));

        // Create a new ontology in the test resources.
        OWLOntologyManager mgr = OWLOntologyManagerFactory.createOWLOntologyManager(null);
        OWLOntology o = mgr.createOntology(dummyiri);
        File f = new File(URI.create(url.toString() + "/dummycharacters.owl"));
        mgr.saveOntology(o, new WriterDocumentTarget(new FileWriter(f)));
        assertTrue(f.exists());

        ((AutoIRIMapper) mapper).update();
        // The old mapper should be able to locate the new ontology.
        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));

        // A new mapper too
        OWLOntologyIRIMapper mapper2 = new AutoIRIMapper(new File(url.toURI()), true);
        assertFalse(dummyiri.equals(mapper2.getDocumentIRI(dummyiri)));

        // cleanup
        f.delete();
    }
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.util.AutoIRIMapper

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.