public static OntModel createOntModel(String ontUri, boolean asGiven, OntModel model) {
if ( model == null ) {
model = createDefaultOntModel();
}
OntModelImpl newOntModel = new OntModelImpl(model.getSpecification(), model);
final String ns_ = asGiven ? ontUri : JenaUtil2.appendFragment(ontUri);
final String base_ = asGiven ? ontUri : JenaUtil2.removeTrailingFragment(ontUri);
// set NS prefixes:
newOntModel.setNsPrefix("", ns_);
Map<String, String> preferredPrefixMap = MdHelper.getPreferredPrefixMap();
for ( String uri : preferredPrefixMap.keySet() ) {
String prefix = preferredPrefixMap.get(uri);
newOntModel.setNsPrefix(prefix, uri);
}
newOntModel.createOntology(base_);
if ( log.isDebugEnabled() ) {
log.debug("New ontology created with namespace " + ns_ + " base " + base_);
}
return newOntModel;