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();
}
use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class SessionResource method asOntologyOWL.
@GET
@Produces(value = { MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML, TEXT_PLAIN })
public Response asOntologyOWL(@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();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
// Export to OWLOntology, the only to support OWL formats.
ResponseBuilder rb = Response.ok(session.export(OWLOntology.class, merge, prefix));
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.semanticweb.owlapi.model.OWLOntology in project stanbol by apache.
the class AbstractOWLApiReasoningService method isConsistent.
/**
* Only check consistency.
*
* Subclasses may want to change how.
*
* @param ontology
* @param rules
* @return
* @throws ReasoningServiceException
*/
@Override
public boolean isConsistent(OWLOntology ontology, List<SWRLRule> rules) throws ReasoningServiceException {
log.debug("Create a input ontology to merge rules in.");
OWLOntology input;
try {
OWLOntologyManager manager = createOWLOntologyManager();
input = manager.createOntology();
Set<SWRLRule> ruleSet = new HashSet<SWRLRule>();
ruleSet.addAll(rules);
manager.addAxioms(input, ruleSet);
input = manager.getOntology(input.getOntologyID());
log.debug("Created ontology: {}", input);
return getReasoner(ontology).isConsistent();
} catch (OWLOntologyCreationException e) {
log.error("An error have been thrown while attempting to create ontology. Message was: {}", e.getLocalizedMessage());
// TODO Add explanation of this exception
throw new ReasoningServiceException();
}
}
Aggregations