// this flag will be only true in the case where an external ontology is to be registered
// and the user indicates that the original base namespace be preserved.
createOntologyResult.setPreserveOriginalBaseNamespace(false);
if ( dataCreationInfo instanceof OtherDataCreationInfo ) {
OtherDataCreationInfo odci = (OtherDataCreationInfo) dataCreationInfo;
TempOntologyInfo toi = odci.getTempOntologyInfo();
createOntologyResult.setPreserveOriginalBaseNamespace(toi != null && toi.isPreserveOriginalBaseNamespace());
}
if ( ! createOntologyResult.isPreserveOriginalBaseNamespace() ) {
// Note: if this is the submission of a new version (ontologyId != null) of an "external" (ie, re-hosted)
// ontology, then set this flag to true
if ( ontologyId != null && ! OntServiceUtil.isOntResolvableUri(createOntologyInfo.getUri()) ) {
createOntologyResult.setPreserveOriginalBaseNamespace(true);
// TODO However, note that we're goint to preserve the URI of the given ontology in this submission,
// which may not coincide with the previous one.
}
}
//}pons
Map<String, String> newValues = createOntologyInfo.getMetadataValues();
////////////////////////////////////////////
// check for errors
if ( createOntologyResult.getError() != null ) {
log.info(": error: " +createOntologyResult.getError());
return createOntologyResult;
}
if ( newValues == null ) {
String error = "Unexpected: no new values assigned for review. Please report this bug";
createOntologyResult.setError(error );
log.info(error);
return createOntologyResult;
}
final String namespaceRoot = defaultNamespaceRoot;
final String orgAbbreviation = newValues.get(OmvMmi.origMaintainerCode.getURI());
String shortName = newValues.get(Omv.acronym.getURI());
// TODO: shortName taken NOT from acronym but from a new field explicitly for the shortName piece
if ( ! createOntologyResult.isPreserveOriginalBaseNamespace() ) {
//pons: check the following if regular assignment of namespace
if ( orgAbbreviation == null ) {
log.info("missing origMaintainerCode");
createOntologyResult.setError("missing origMaintainerCode");
return createOntologyResult;
}
if ( shortName == null ) {
if ( ontologyId == null ) {
// This is a new submission.
log.info("missing acronym (to be used as shortName)");
createOntologyResult.setError("missing acronym (to be used as shortName)");
return createOntologyResult;
}
else {
// take from previous information
String originalShortName = createOntologyInfo.getShortName();
shortName = originalShortName;
}
}
if ( ontologyId == null ) {
// This is a new submission. We need to check for any conflict with a preexisting
// ontology in the repository with the same shortName+orgAbbreviation combination
//
if ( ! Util2.checkNoPreexistingOntology(namespaceRoot, orgAbbreviation, shortName, createOntologyResult) ) {
return createOntologyResult;
}
}
else {
// This is a submission of a *new version* of an existing ontology.
// We need to check the shortName+orgAbbreviation combination as any changes here
// would imply a *new* ontology, not a new version.
//
String originalOrgAbbreviation = createOntologyInfo.getAuthority();
String originalShortName = createOntologyInfo.getShortName();
if ( ! Util2.checkUriKeyCombinationForNewVersion(
originalOrgAbbreviation, originalShortName,
orgAbbreviation, shortName, createOntologyResult) ) {
return createOntologyResult;
}
}
}
// Else: see below, where we obtain the original namespace.
////////////////////////////////////////////////////////////////////////////
// section to create the ontology the base:
if ( dataCreationInfo instanceof VocabularyDataCreationInfo ) {
// vocabulary (voc2rdf) case:
VocabularyDataCreationInfo vocabularyDataCreationInfo = (VocabularyDataCreationInfo) dataCreationInfo;
_createTempVocabularyOntology(createOntologyInfo, vocabularyDataCreationInfo, createOntologyResult);
if ( createOntologyResult.getError() != null ) {
return createOntologyResult;
}
}
else if ( dataCreationInfo instanceof MappingDataCreationInfo ) {
// mapping (vine case):
MappingDataCreationInfo mappingDataCreationInfo = (MappingDataCreationInfo) dataCreationInfo;
_createTempMappingOntology(createOntologyInfo, mappingDataCreationInfo, createOntologyResult);
if ( createOntologyResult.getError() != null ) {
return createOntologyResult;
}
}
else if ( dataCreationInfo instanceof OtherDataCreationInfo) {
// external ontology case: the base ontology is already available, just use it
// by setting the full path in the createOntologyResult:
OtherDataCreationInfo otherDataCreationInfo = (OtherDataCreationInfo) dataCreationInfo;
TempOntologyInfo tempOntologyInfo = otherDataCreationInfo.getTempOntologyInfo();
String full_path;
if ( tempOntologyInfo != null ) {
// new contents were provided. Use that: