NameProvider nameProvider;
if (hasImports) {
// if the ontology has imports
// use it as secondary lookup for labels
final NameProvider primary = new OBODocNameProvider(result);
final NameProvider secondary = new OWLOntologyNameProvider(
ontology, primary.getDefaultOboNamespace());
// combine primary and secondary name provider
nameProvider = new NameProvider() {
@Override
public String getName(String id) {
String name = primary.getName(id);
if (name != null) {
return name;
}
return secondary.getName(id);
}
@Override
public String getDefaultOboNamespace() {
return primary.getDefaultOboNamespace();