//////////////////////////////////////////////////
// transfer any preexisting attributes, and then remove all properties from
// pre-existing ontRes so just the new OntModel gets added.
if ( ontRes != null ) {
for ( Statement st : prexistStatements ) {
Property prd = st.getPredicate();
//
// Do not tranfer pre-existing/pre-assigned-above attributes
//
String newValue = newValues.get(prd.getURI());
if ( newValue == null || newValue.trim().length() == 0 ) {
log.info(" Transferring: " +st.getSubject()+ " :: " +prd+ " :: " +st.getObject());
newOntModel.add(ont_, prd, st.getObject());
}
else {
log.info(" Removing pre-existing values for predicate: " +prd+ " because of new value " +newValue);
newOntModel.removeAll(ont_, prd, null);
}
}
if ( ! createOntologyResult.isPreserveOriginalBaseNamespace() ) {
//
// Only, when we're creating a new model, ie., per the new namespace, do the following removals.
// (If we did this on a model with the same original namespace, we would remove the owl:Ontology
// entry altogether and get an "rdf:Description" instead.
//
log.info("Removing original OWL.Ontology individual");
ontRes.removeProperties();
// TODO the following may be unnecesary but doesn't hurt:
model.remove(ontRes, RDF.type, OWL.Ontology);
}
}
///////////////////////////////////////////////////////
// Update attributes in model:
Map<String, Property> uriPropMap = MdHelper.getUriPropMap();
for ( String uri : newValues.keySet() ) {
String value = newValues.get(uri).trim();
if ( value.length() > 0 ) {
Property prop = uriPropMap.get(uri);
if ( prop == null ) {
log.info("No property found for uri='" +uri+ "'");
continue;
}