* get all loaded remote reasoner configuration(only name)
*/
private void getAllLoadedReasoners(){
config.loadRemoteReasonerConfiguration();
ReasonerRegistry registry = HeraklesManager.getReasonerRegistry();
ModelManager modelManager = workspace.getEditorKit().getModelManager();
if(modelManager instanceof OWLModelManager){
OWLOntologyManager manager = ((OWLModelManager)modelManager).getOWLOntologyManager();
Set<String> types = config.getRemoteReasonerTypes();
reasoners.clear();
reasonerTypes.clear();
reasonerIndex.clear();
reasonerProperties.clear();
for(String type: types){
Set<Integer> indexs = config.getRemoteReasonerIndex(type);
for(int index: indexs){
String reasonerID = type + "-" + index;
// if the reasoner properties exists, the connection test will be skipped
if(reasonerProperties.containsKey(reasonerID)){
reasoners.add(reasonerID);
reasonerTypes.put(reasonerID, type);
reasonerIndex.put(reasonerID, index);
continue;
}
// get the host and rmi name of the reasoner
String name = config.getRemoteReasonerName(type, index);
String host = config.getRemoteReasonerHost(type, index);
String port = config.getRemoteReasonerPort(type, index);
Properties pro = null;
// try {
ReasonerAdapter adapter = null;
boolean isNewReasoner = false;
if(!registry.containsReasoner(name, host, port)){
isNewReasoner = true;
adapter = registry.registerReasoner(manager, name, host, port);
} else {
adapter = registry.getReasoner(name, host, port);
}
pro = adapter.getReasonerProperties();
// test the reasoner types and correct the configuration
String proType = pro.getProperty("name").toUpperCase();
if(!proType.equals(type)){
config.removeRemoteReasoner(type, index);
int newIndex = config.addRemoteReasoner(proType, name, host, port);
reasonerID = proType + "-" + newIndex;
reasonerTypes.put(reasonerID, proType);
reasonerIndex.put(reasonerID, newIndex);
} else {
reasonerTypes.put(reasonerID, type);
reasonerIndex.put(reasonerID, index);
}
reasoners.add(reasonerID);
if(isNewReasoner){
registry.setReasonerID(reasonerID, adapter);
registry.createStatisticListener(adapter);
}
// load ontology and classify
// try {
// adapter.clearOntologies();
// Set<OWLOntology> ontologies = new HashSet<OWLOntology>(((OWLModelManager)modelManager).getActiveOntologies());
// adapter.loadOntologies(ontologies);
// adapter.classify();
// } catch (OWLReasonerException e) {
// e.printStackTrace();
// }
reasonerProperties.put(reasonerID, pro);
// } catch (RemoteException e1) {
//
// logger.debug("RMI Remote Exception"+ type + ":" + index);
// } catch (NotBoundException e1) {
// config.removeRemoteReasoner(type, index);
// logger.info("Reasoner " + host + ":" + name + " doesn't exist");
// }
}
}
registry.setBound();
}
}