Skip to content

Commit

Permalink
Duplicate Metadata: warn and use first occurence
Browse files Browse the repository at this point in the history
  • Loading branch information
martinweismann committed Jun 9, 2020
1 parent f2b3e81 commit 95f1641
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
32 changes: 17 additions & 15 deletions Source/Model/Reader/NMR_ModelReaderNode_ModelBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,25 @@ namespace NMR {
if (m_pModel->hasMetaData(sKey)) {
m_pWarnings->addWarning(NMR_ERROR_DUPLICATEMETADATA, mrwInvalidOptionalValue);
}
std::string sNameSpace, sName;
decomposeKeyIntoNamespaceAndName(sKey, sNameSpace, sName);
if (!sNameSpace.empty()) {
std::string sNameSpaceURI;
if (!pXMLReader->GetNamespaceURI(sNameSpace, sNameSpaceURI)) {
m_pWarnings->addException(CNMRException(NMR_ERROR_METADATA_COULDNOTGETNAMESPACE), mrwInvalidOptionalValue);
sNameSpaceURI = sNameSpace;
}
m_pModel->addMetaData(sNameSpaceURI, sName, sValue, sType, bPreserve);
}
else {
// default namespace
if (CModelMetaData::isValidNamespaceAndName("", sName)) {
m_pModel->addMetaData("", sName, sValue, sType, bPreserve);
std::string sNameSpace, sName;
decomposeKeyIntoNamespaceAndName(sKey, sNameSpace, sName);
if (!sNameSpace.empty()) {
std::string sNameSpaceURI;
if (!pXMLReader->GetNamespaceURI(sNameSpace, sNameSpaceURI)) {
m_pWarnings->addException(CNMRException(NMR_ERROR_METADATA_COULDNOTGETNAMESPACE), mrwInvalidOptionalValue);
sNameSpaceURI = sNameSpace;
}
m_pModel->addMetaData(sNameSpaceURI, sName, sValue, sType, bPreserve);
}
else {
// default namespace
if (CModelMetaData::isValidNamespaceAndName("", sName)) {
m_pModel->addMetaData("", sName, sValue, sType, bPreserve);
}
else
m_pWarnings->addException(CNMRException(NMR_ERROR_UNKNOWNMETADATA), mrwInvalidOptionalValue);
}
else
m_pWarnings->addException(CNMRException(NMR_ERROR_UNKNOWNMETADATA), mrwInvalidOptionalValue);
}
}
else {
Expand Down
32 changes: 17 additions & 15 deletions Source/Model/Reader/v100/NMR_ModelReaderNode100_MetaDataGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,25 @@ namespace NMR {
if (m_MetaDataGroup->hasMetaData(sKey)) {
m_pWarnings->addWarning(NMR_ERROR_DUPLICATEMETADATA, mrwInvalidOptionalValue);
}
std::string sNameSpace, sName;
decomposeKeyIntoNamespaceAndName(sKey, sNameSpace, sName);
if (!sNameSpace.empty()) {
std::string sNameSpaceURI;
if (!pXMLReader->GetNamespaceURI(sNameSpace, sNameSpaceURI)) {
m_pWarnings->addException(CNMRException(NMR_ERROR_METADATA_COULDNOTGETNAMESPACE), mrwInvalidOptionalValue);
sNameSpaceURI = sNameSpace;
}
m_MetaDataGroup->addMetaData(sNameSpaceURI, sName, sValue, sType, bPreserve);
}
else {
// default namespace
if (CModelMetaData::isValidNamespaceAndName("", sName)) {
m_MetaDataGroup->addMetaData("", sName, sValue, sType, bPreserve);
std::string sNameSpace, sName;
decomposeKeyIntoNamespaceAndName(sKey, sNameSpace, sName);
if (!sNameSpace.empty()) {
std::string sNameSpaceURI;
if (!pXMLReader->GetNamespaceURI(sNameSpace, sNameSpaceURI)) {
m_pWarnings->addException(CNMRException(NMR_ERROR_METADATA_COULDNOTGETNAMESPACE), mrwInvalidOptionalValue);
sNameSpaceURI = sNameSpace;
}
m_MetaDataGroup->addMetaData(sNameSpaceURI, sName, sValue, sType, bPreserve);
}
else {
// default namespace
if (CModelMetaData::isValidNamespaceAndName("", sName)) {
m_MetaDataGroup->addMetaData("", sName, sValue, sType, bPreserve);
}
else
m_pWarnings->addException(CNMRException(NMR_ERROR_UNKNOWNMETADATA), mrwInvalidOptionalValue);
}
else
m_pWarnings->addException(CNMRException(NMR_ERROR_UNKNOWNMETADATA), mrwInvalidOptionalValue);
}
}
else {
Expand Down

0 comments on commit 95f1641

Please sign in to comment.