if (peOutputURI.equals(peInputURI)) {
iri1 = IRI.create(peOutput);
ontology1 = manager.loadOntologyFromOntologyDocument(iri1);
LOG.debug("Loaded ontology: " + ontology1);
if (!ontology1.containsClassInSignature(iri1)) {
throw new ActivityUserException(
new ActivityInferenceException(
"ActivityInferenceException",
"Ontology does not contain class: " + iri1));
}
} else {
mOutputBlockWriter.write("disjoint");
}
if (ontology2 != null) {
// two different domain ontologies
mOutputBlockWriter.write("disjoint");
} else {
// same domain ontology
OWLReasonerFactory reasonerFactory = null;
reasonerFactory = new Reasoner.ReasonerFactory();
OWLReasoner reasoner = reasonerFactory
.createReasoner(ontology1);
OWLDataFactory fac = manager.getOWLDataFactory();
OWLClass peOutputClass = fac.getOWLClass(IRI.create(peOutput));
OWLClass peInputClass = fac.getOWLClass(IRI.create(peInput));
if (equivalentClasses(peOutputClass, peInputClass, ontology1,
reasoner)) {
mOutputBlockWriter.write("equivalent");
} else if (subclassOf(peOutputClass, peInputClass, reasoner)) {
mOutputBlockWriter.write("subClassOf");
} else if (disjointClasses(peOutputClass, peInputClass,
reasoner)) {
mOutputBlockWriter.write("disjoint");
} else {
mOutputBlockWriter.write("convertible");
}
}
} catch (OWLOntologyCreationIOException e) {
// IOExceptions during loading get wrapped in an
// OWLOntologyCreationIOException
IOException ioException = e.getCause();
if (ioException instanceof UnknownHostException) {
throw new ActivityUserException(new ActivityInferenceException(
"UnknownHostException",
"Could not load ontology. Unknown host: "
+ ioException.getMessage()));
} else {
throw new ActivityUserException(new ActivityInferenceException(
"ActivityInferenceException",
"Could not load ontology: "
+ ioException.getClass().getSimpleName() + " "
+ ioException.getMessage()));
}
} catch (UnparsableOntologyException e) {
// If there was a problem loading an ontology because there are
// syntax errors in the document (file) that
// represents the ontology then an UnparsableOntologyException is
// thrown
LOG.debug("Could not parse the ontology: " + e.getMessage());
// A map of errors can be obtained from the exception
Map<OWLParser, OWLParserException> exceptions = e.getExceptions();
// The map describes which parsers were tried and what the errors
// were
for (OWLParser parser : exceptions.keySet()) {
LOG.debug("Tried to parse the ontology with the "
+ parser.getClass().getSimpleName() + " parser");
LOG.debug("Failed because: "
+ exceptions.get(parser).getMessage());
}
throw new ActivityUserException(new ActivityInferenceException(
"ActivityInferenceException",
"Could not parse the ontology: " + e.getMessage()));
} catch (UnloadableImportException e) {
// If our ontology contains imports and one or more of the imports
// could not be loaded then an
// UnloadableImportException will be thrown (depending on the
// missing imports handling policy)
OWLOntologyCreationException cause = e
.getOntologyCreationException();
throw new ActivityUserException(new ActivityInferenceException(
"ActivityInferenceException", "Could not load import: "
+ e.getImportsDeclaration() + "Reason: "
+ cause.getMessage()));
} catch (OWLOntologyCreationException e) {
throw new ActivityUserException(new ActivityInferenceException(
"ActivityInferenceException", "Reason: " + e.getMessage()));
} catch (PipeClosedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PipeIOException e) {