use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class TestOntologyRegistry method testLoopInLibrary.
@Test
public void testLoopInLibrary() throws Exception {
// Create the model from the looping registry.
OWLOntology oReg = virginOntologyManager.loadOntology(Locations._REGISTRY_TEST_LOOP);
Set<Registry> rs = regman.createModel(Collections.singleton(oReg));
// There has to be a single registry, with the expected number of children (one).
assertEquals(1, rs.size());
Registry r = rs.iterator().next();
assertTrue(r.hasChildren());
int count = 1;
assertEquals(count, r.getChildren().length);
// There are no libreries without ontologies in the test registry.
for (RegistryItem child : r.getChildren()) {
assertTrue(child instanceof Library);
// Check both parent-child relations.
assertTrue(child.hasChildren());
for (RegistryItem grandchild : child.getChildren()) {
assertTrue(grandchild instanceof RegistryOntology);
assertTrue(grandchild.hasParents());
assertTrue(Arrays.asList(grandchild.getParents()).contains(child));
}
}
}
use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class TestOntologyRegistry method testRegistryUnion.
/**
* Verifies that, when loading multiple registries that add library information to each other, the overall
* model reflects the union of these registries.
*
* @throws Exception
*/
@Test
public void testRegistryUnion() throws Exception {
// Create the model from two overlapping registries.
Set<OWLOntology> regs = new HashSet<OWLOntology>();
regs.add(virginOntologyManager.loadOntology(Locations._REGISTRY_TEST));
regs.add(virginOntologyManager.loadOntology(Locations._REGISTRY_TEST_ADDITIONS));
Set<Registry> rs = regman.createModel(regs);
for (Registry r : rs) {
// The nonexistent library should also be included, if using the more powerful algorithm.
// set to 2 if using the less powerful algorithm.
int count = 3;
if (Locations._REGISTRY_TEST.equals(r.getIRI()))
assertEquals(count, r.getChildren().length);
else if (Locations._REGISTRY_TEST_ADDITIONS.equals(r.getIRI()))
assertEquals(1, r.getChildren().length);
// Check that we find the expected ontology in the expected library.
for (RegistryItem lib : r.getChildren()) {
if (Locations.LIBRARY_TEST1.equals(lib.getIRI())) {
boolean found = false;
for (RegistryItem child : lib.getChildren()) {
if (child instanceof RegistryOntology && Locations.ONT_TEST1.equals(child.getIRI())) {
found = true;
break;
}
}
assertTrue(found);
break;
}
}
}
}
use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class TestOntologyRegistry method testPopulateRegistry.
/**
* Verifies that a call to {@link RegistryManager#createModel(Set)} with a registry location creates the
* object model accordingly.
*
* @throws Exception
*/
@Test
public void testPopulateRegistry() throws Exception {
// Create the model from a single registry.
OWLOntology oReg = virginOntologyManager.loadOntology(Locations._REGISTRY_TEST);
Set<Registry> rs = regman.createModel(Collections.singleton(oReg));
// There has to be a single registry, with the expected number of children.
assertEquals(1, rs.size());
Registry r = rs.iterator().next();
assertTrue(r.hasChildren());
// The nonexistent library should also be included, if using the more powerful algorithm.
// set to 2 if using the less powerful algorithm.
int count = 3;
assertEquals(count, r.getChildren().length);
// There are no libraries without ontologies in the test registry.
for (RegistryItem ri : r.getChildren()) assertTrue(ri.hasChildren());
}
use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class ScopeResource method getCustomSpaceOWL.
@GET
@Path("/custom")
@Produces(value = { RDF_XML, TURTLE, X_TURTLE, MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML, TEXT_PLAIN })
public Response getCustomSpaceOWL(@PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
scope = onm.getScope(scopeid);
OntologySpace space = scope.getCustomSpace();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
OWLOntology o = space.export(OWLOntology.class, merge, prefix);
ResponseBuilder rb = Response.ok(o);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class SessionResource method asOntologyMixed.
@GET
@Produces(value = { RDF_XML, TURTLE, X_TURTLE })
public Response asOntologyMixed(@PathParam(value = "id") String sessionId, @PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context HttpHeaders headers) {
session = sesMgr.getSession(sessionId);
if (session == null)
return Response.status(NOT_FOUND).build();
ResponseBuilder rb;
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
// Export smaller graphs to OWLOntology due to the more human-readable rendering.
if (merge)
rb = Response.ok(session.export(ImmutableGraph.class, merge, prefix));
else
rb = Response.ok(session.export(OWLOntology.class, merge, prefix));
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
Aggregations