Set<PolytomousKeyNode> nodes = state.getUnmatchedLeads().getNodes(unmatchedKey);\r
for(PolytomousKeyNode nodeToMatch: nodes){\r
for (PolytomousKeyNode childNode : childList){\r
- nodeToMatch.addChild(childNode);\r
- //just to be on the save side\r
- nodeToMatch.refreshNodeNumbering();\r
+ try {\r
+ nodeToMatch.addChild(childNode);\r
+ //just to be on the save side\r
+ nodeToMatch.refreshNodeNumbering();\r
+ } catch (Exception e) {\r
+ String message = "An exception occurred when trying to add a key node child or to referesh the node numbering: " + e.getMessage();\r
+ fireWarningEvent(message, parentEvent, 6);\r
+ }\r
}\r
state.getUnmatchedLeads().removeNode(unmatchedKey, nodeToMatch);\r
}\r
\r
//try to find matching lead nodes \r
UnmatchedLeadsKey leadsKey = UnmatchedLeadsKey.NewInstance(num, nameString);\r
- Set<PolytomousKeyNode> matchingNodes = handleMatchingNodes(state, taxon, leadsKey);\r
+ Set<PolytomousKeyNode> matchingNodes = handleMatchingNodes(state, event, taxon, leadsKey);\r
\r
if (num != null){//same without using the num\r
UnmatchedLeadsKey noNumLeadsKey = UnmatchedLeadsKey.NewInstance("", nameString);\r
- Set<PolytomousKeyNode> noNumMatchingNodes = handleMatchingNodes(state, taxon, noNumLeadsKey);\r
+ Set<PolytomousKeyNode> noNumMatchingNodes = handleMatchingNodes(state, event, taxon, noNumLeadsKey);\r
if(noNumMatchingNodes.size() > 0){\r
String message ="Taxon matches additional key node when not considering <num> attribute in taxontitle. This may be correct but may also indicate an error.";\r
fireWarningEvent(message, event, 1);\r
\r
}\r
\r
- private Set<PolytomousKeyNode> handleMatchingNodes(MarkupImportState state, Taxon taxon, UnmatchedLeadsKey leadsKey) {\r
+ private Set<PolytomousKeyNode> handleMatchingNodes(MarkupImportState state, XMLEvent event, Taxon taxon, UnmatchedLeadsKey leadsKey) {\r
Set<PolytomousKeyNode> matchingNodes = state.getUnmatchedLeads().getNodes(leadsKey);\r
for (PolytomousKeyNode matchingNode : matchingNodes){\r
state.getUnmatchedLeads().removeNode(leadsKey, matchingNode);\r
matchingNode.setTaxon(taxon);\r
//just to be on the save side\r
- matchingNode.refreshNodeNumbering();\r
+ try{ \r
+ matchingNode.refreshNodeNumbering();\r
+ } catch (Exception e) {\r
+ String message = "An exception occurred when trying to referesh the node numbering: " + e.getMessage();\r
+ fireWarningEvent(message, event, 6);\r
+ }\r
state.getPolytomousKeyNodesToSave().add(matchingNode);\r
}\r
return matchingNodes;\r