Skip to content

Commit d32db56

Browse files
committed
Check for pre-existing OTT ID before checking for homonym.
1 parent 0bd5163 commit d32db56

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

otc/taxonomy/patching.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,16 @@ bool_str_t PatchableTaxonomy::add_new_taxon(OttId oid,
290290
auto & tree = this->get_mutable_tax_tree();
291291
auto & rt_data = tree.get_data();
292292

293-
// 1. Check if the new taxon is a homonym of an existing taxon.
293+
// 1. Check if the OTT ID is already used.
294+
auto itnit = included_taxon_from_id(oid);
295+
auto itrit = rt_data.id_to_record.find(oid);
296+
if (itnit != nullptr || itrit != rt_data.id_to_record.end()) {
297+
std::string expl = "OTT ID " + std::to_string(oid);
298+
expl += " is already used.";
299+
return bool_str_t{false, expl};
300+
}
301+
302+
// 2. Check if the new taxon is a homonym of an existing taxon.
294303
auto nm_nd_it = rt_data.name_to_node.find(name);
295304
if (nm_nd_it == rt_data.name_to_node.end()) {
296305
if (homonym_of != nullptr) {
@@ -302,15 +311,6 @@ bool_str_t PatchableTaxonomy::add_new_taxon(OttId oid,
302311
return bool_str_t{false, expl};
303312
}
304313

305-
// 2. Check if the OTT ID is already used.
306-
auto itnit = included_taxon_from_id(oid);
307-
auto itrit = rt_data.id_to_record.find(oid);
308-
if (itnit != nullptr || itrit != rt_data.id_to_record.end()) {
309-
std::string expl = "OTT ID " + std::to_string(oid);
310-
expl += " is already used.";
311-
return bool_str_t{false, expl};
312-
}
313-
314314
// 3. Find the parent taxon by its OTT ID.
315315
RTRichTaxNode * par_ptr = const_cast<RTRichTaxNode *>(included_taxon_from_id(parent_id));
316316
if (par_ptr == nullptr) {

0 commit comments

Comments
 (0)