if ( log.isDebugEnabled() ) {
log.debug("prepareOntologyMetadata: ontologyUri=" +ontologyInfo.getUri());
}
OntologyMetadata ontologyMetadata = ontologyInfo.getOntologyMetadata();
Resource ontRes = JenaUtil2.getFirstIndividual(model, OWL.Ontology);
StringBuilder moreDetails = new StringBuilder();
Map<String, Property> uriPropMap = MdHelper.getUriPropMap();
Map<String,String> originalValues = new HashMap<String, String>();
if ( ontRes != null ) {
//
// Get values from the existing ontology resource
//
for ( AttrGroup attrGroup : metadataBaseInfo.getAttrGroups() ) {
for ( AttrDef attrDef : attrGroup.getAttrDefs() ) {
// get value of MMI property:
Property mmiProp = uriPropMap.get(attrDef.getUri());
String prefixedMmi = MdHelper.prefixedName(mmiProp);
String value = JenaUtil2.getValue(ontRes, mmiProp);
// DC equivalent, which is obtained if necessary
Property dcProp = null;
if (value == null) {
// try a DC equivalent to use:
dcProp = MdHelper.getEquivalentDcProperty(mmiProp);
if ( dcProp != null ) {
value = JenaUtil2.getValue(ontRes, dcProp);
}
}
if ( value != null ) {
// get value:
if ( log.isDebugEnabled() ) {
log.debug("Assigning: " +attrDef.getUri()+ " = " + value);
}
originalValues.put(attrDef.getUri(), value);
// Special case: Omv.acronym/OmvMmi.shortNameUri
if ( Omv.acronym.getURI().equals(attrDef.getUri()) ) {
// add also the value of OmvMmi.shortNameUri:
String shortNameValue = JenaUtil2.getValue(ontRes, OmvMmi.shortNameUri);
if ( log.isDebugEnabled() ) {
log.debug("Also assigning " +OmvMmi.shortNameUri.getURI()+ " = " +shortNameValue);
}
originalValues.put(OmvMmi.shortNameUri.getURI(), shortNameValue);
}
// add detail:
if ( dcProp != null ) {
String prefixedDc = MdHelper.prefixedName(dcProp);
_addDetail(moreDetails, prefixedMmi, "not present", "Will use " +prefixedDc);
}
else {
_addDetail(moreDetails, prefixedMmi, "present", " ");
}
}
else {
if ( attrDef.isRequired() && ! attrDef.isInternal() ) {
if ( dcProp != null ) {
String prefixedDc = MdHelper.prefixedName(dcProp);
_addDetail(moreDetails, prefixedMmi, "not present", "and " +prefixedDc+ " not present either");
}
else {
_addDetail(moreDetails, prefixedMmi, "not present", " not equivalent DC");
}
}
}
}
}
}
else {
//
// No ontology resource. Check required attributes to report in the details:
//
for ( AttrGroup attrGroup : metadataBaseInfo.getAttrGroups() ) {
for ( AttrDef attrDef : attrGroup.getAttrDefs() ) {
if ( attrDef.isRequired() && ! attrDef.isInternal() ) {
Property mmiProp = uriPropMap.get(attrDef.getUri());
String prefixedMmi = MdHelper.prefixedName(mmiProp);
_addDetail(moreDetails, prefixedMmi, "not present", "required");
}
}
}
}
// add the new details if any:
if ( moreDetails.length() > 0 ) {
String details = ontologyMetadata.getDetails();
if ( details == null ) {
ontologyMetadata.setDetails(moreDetails.toString());
}
else {
ontologyMetadata.setDetails(details + "\n" +moreDetails.toString());
}
}
ontologyMetadata.setOriginalValues(originalValues);
// associate the original base URI:
String uri = model.getNsPrefixURI("");
if ( uri != null ) {
String base_ = JenaUtil2.removeTrailingFragment(uri);