boolean hasImports = ontology.getImports().isEmpty() == false;
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();
}
};
} else {
nameProvider = new OBODocNameProvider(result);
}
OBOFormatWriter oboFormatWriter = new OBOFormatWriter();
oboFormatWriter.setCheckStructure((Boolean) format.getParameter(
OBODocumentFormat.VALIDATION, Boolean.TRUE));
oboFormatWriter.write(result, new BufferedWriter(writer),