use of org.apache.stanbol.ontologymanager.sources.owlapi.ParentPathInputSource in project stanbol by apache.
the class TestClerezzaSpaces method setup.
@BeforeClass
public static void setup() throws Exception {
offline = new OfflineConfigurationImpl(new Hashtable<String, Object>());
ScopeRegistry reg = new ScopeRegistryImpl();
// This one is created from scratch
Graph ont2 = ClerezzaOWLUtils.createOntology(baseIri2.toString());
minorSrc = new GraphSource(ont2.getImmutableGraph());
dropSrc = getLocalSource("/ontologies/droppedcharacters.owl");
nonexSrc = getLocalSource("/ontologies/nonexistentcharacters.owl");
inMemorySrc = new ParentPathInputSource(new File(TestClerezzaSpaces.class.getResource("/ontologies/maincharacters.owl").toURI()));
OWLDataFactory df = OWLManager.getOWLDataFactory();
OWLClass cHuman = df.getOWLClass(IRI.create(baseIri + "/" + Constants.humanBeing));
OWLIndividual iLinus = df.getOWLNamedIndividual(IRI.create(baseIri + "/" + Constants.linus));
linusIsHuman = df.getOWLClassAssertionAxiom(cHuman, iLinus);
factory = new ClerezzaCollectorFactory(new ClerezzaOntologyProvider(tcManager, offline, parser), new Hashtable<String, Object>());
factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
}
use of org.apache.stanbol.ontologymanager.sources.owlapi.ParentPathInputSource in project stanbol by apache.
the class TestStorage method storageOnScopeCreation.
@Test
public void storageOnScopeCreation() throws Exception {
assertEquals(1, ontologyProvider.getStore().listGraphs().size());
// This one has an import that we want to hijack locally, so we use the ParentPathInputSource.
OntologyInputSource<?> ois = new ParentPathInputSource(new File(getClass().getResource("/ontologies/minorcharacters.owl").toURI()));
Scope sc = onManager.createOntologyScope(scopeId, ois);
Set<Triple> triples = new HashSet<Triple>();
for (IRI iri : ontologyProvider.getStore().listGraphs()) {
log.info("{}", iri.toString());
IRI entity = new IRI(Constants.PEANUTS_MINOR_BASE + "#" + Constants.truffles);
ImmutableGraph ctx = new GraphNode(entity, ontologyProvider.getStore().getGraph(iri)).getNodeContext();
Iterator<Triple> it = ctx.iterator();
while (it.hasNext()) triples.add(it.next());
}
assertFalse(ontologyProvider.getStore().listGraphs().isEmpty());
assertEquals(3, triples.size());
}
use of org.apache.stanbol.ontologymanager.sources.owlapi.ParentPathInputSource in project stanbol by apache.
the class TestOntologyCollectors method spacePreservesImports.
@Test
public void spacePreservesImports() throws Exception {
InputStream content = getClass().getResourceAsStream("/ontologies/characters_all.owl");
URL url = getClass().getResource("/ontologies/characters_all.owl");
OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
mgr.addOntologyLoaderListener(new OWLOntologyLoaderListener() {
@Override
public void startedLoadingOntology(LoadingStartedEvent arg0) {
}
@Override
public void finishedLoadingOntology(LoadingFinishedEvent arg0) {
log.info((arg0.isSuccessful() ? "Loaded" : "Failed") + (arg0.isImported() ? " imported " : " ") + "ontology " + arg0.getDocumentIRI());
}
});
mgr.addIRIMapper(new PhonyIRIMapper(null));
File f = new File(url.toURI());
OntologyInputSource<OWLOntology> src = new ParentPathInputSource(f, mgr);
// OntologyInputSource<OWLOntology> src = new RootOntologyIRISource(IRI.create(f), mgr);
// OntologyInputSource<OWLOntology> src = new OntologyContentInputSource(content,mgr);
OWLOntology original = src.getRootOntology();
Assert.assertNotNull(original);
OntologySpace spc = new CustomSpaceImpl("Test", scopeNs, ontologyProvider);
spc.addOntology(src);
}
use of org.apache.stanbol.ontologymanager.sources.owlapi.ParentPathInputSource in project stanbol by apache.
the class TestOntologySpaces method getLocalSource.
private static OntologyInputSource<OWLOntology> getLocalSource(String resourcePath, OWLOntologyManager mgr) throws OWLOntologyCreationException, URISyntaxException {
URL url = TestOntologySpaces.class.getResource(resourcePath);
File f = new File(url.toURI());
return new ParentPathInputSource(f, mgr != null ? mgr : OWLOntologyManagerFactory.createOWLOntologyManager(onManager.getOfflineConfiguration().getOntologySourceLocations().toArray(new IRI[0])));
}
Aggregations