use of org.protege.editor.owl.model.inference.ProtegeOWLReasonerInfo in project snow-owl by b2ihealthcare.
the class ReasonerTaxonomyInferrer method createReasoner.
private static OWLReasoner createReasoner(final String reasonerId, final OWLOntology owlOntology) {
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
final IExtension[] extensions = extensionPoint.getExtensions();
for (final IExtension extension : extensions) {
final IConfigurationElement[] configurationElements = extension.getConfigurationElements();
final String extensionId = extension.getUniqueIdentifier();
if (reasonerId.equals(extensionId)) {
final Optional<IConfigurationElement> classElement = Arrays.asList(configurationElements).stream().filter(e -> CLASS_ELEMENT.equals(e.getName())).findFirst();
if (!classElement.isPresent()) {
throw new ReasonerApiException("Couldn't create reasoner info instance for extension '%s'.", reasonerId);
}
final ProtegeOWLReasonerInfo reasonerInfo;
try {
reasonerInfo = (ProtegeOWLReasonerInfo) classElement.get().createExecutableExtension(VALUE_ATTRIBUTE);
reasonerInfo.initialise();
} catch (final Exception e) {
throw new ReasonerApiException("Couldn't create reasoner info instance for extension '%s'.", reasonerId, e);
}
final OWLReasonerFactory reasonerFactory = reasonerInfo.getReasonerFactory();
final OWLReasonerConfiguration reasonerConfiguration = reasonerInfo.getConfiguration(new LoggingProgressMonitor(LOGGER));
return reasonerFactory.createNonBufferingReasoner(owlOntology, reasonerConfiguration);
}
}
throw new ReasonerApiException("Couldn't create reasoner info instance for extension '%s'.", reasonerId);
}
Aggregations